From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NO_DNS_FOR_FROM,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) by gnuweeb.org (Postfix) with ESMTPSA id 5C3D48060F for ; Mon, 29 Aug 2022 04:21:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1661746883; bh=/xszUl8r/E9g/OE7NW7MuvAgzRnk0M3H5Bjjs9x+Ra8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=MT51g2LoC2s8x6ROQnTU3uIvplqHTj5iHWZgkokR4fiKTEtqYwk8JNwTjxtSFHb2A ZSPX+3Dc2Z4PwJgCw8gdHS2F+E8A6DiPlD20qAYZG4liBfn9nhnO20nuT6qqTsDe4Y vC+nwsYW3gY9empTkozjZZ7NjBW7vhcJnx2qkupZxQkmz7YPISK7YzeKLIn0r1TtuY aUX5Ijnpfxs/TThGbO+WD5n9VSXRx0sOeBw6QWxPN2wv+uzCTdmaDDlPUUoI7uIK4+ VLsylmSbUzMMWR78kPpI1aBIWH3JnwvSNtzpcCbwzt/JilYLVmmTd/oVgPjNybTD98 h8TKjGuBFnbsg== Received: by mail-lj1-f171.google.com with SMTP id k18so462295lji.13 for ; Sun, 28 Aug 2022 21:21:23 -0700 (PDT) X-Gm-Message-State: ACgBeo2kG8c6uHWnAtsMCHED9hSu7KXO4E1DuozI5mfzBILJQ2NJaZL6 IKBaDZWzN84UuuPTbwy84q2GBxNHPtrct72U0gQ= X-Google-Smtp-Source: AA6agR4wBYtKY/k+c6s4nRGDd9z3UYep8HxPRAZa6F2127yhX02XI3m1FUOy2A7ztAgdeyufsiD1yGNx5YWWm3LOc/w= X-Received: by 2002:a2e:9604:0:b0:25e:4ed7:ef45 with SMTP id v4-20020a2e9604000000b0025e4ed7ef45mr4836803ljh.389.1661746881481; Sun, 28 Aug 2022 21:21:21 -0700 (PDT) MIME-Version: 1.0 References: <20220829011127.3150320-1-ammarfaizi2@gnuweeb.org> <20220829011127.3150320-2-ammarfaizi2@gnuweeb.org> In-Reply-To: <20220829011127.3150320-2-ammarfaizi2@gnuweeb.org> From: Alviro Iskandar Setiawan Date: Mon, 29 Aug 2022 11:21:10 +0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH v1 1/2] chnet: Prepare global struct ch_thpool array To: Ammar Faizi Cc: Muhammad Rizki , Kanna Scarlet , "GNU/Weeb Mailing List" Content-Type: text/plain; charset="UTF-8" List-Id: On Mon, Aug 29, 2022 at 8:11 AM Ammar Faizi wrote: > + g_max_ch_thpool = std::thread::hardware_concurrency() - 1; > + if (g_max_ch_thpool < 1) > + g_max_ch_thpool = 1; this is wrong, std::thread::hardware_concurrency() should be treated as a hint, if this happens to return 0, then the sub with 1 will make it ~0, that will definitely hit ENOMEM. this should be: g_max_ch_thpool = std::thread::hardware_concurrency(); if (g_max_ch_thpool <= 1) g_max_ch_thpool = 1; else g_max_ch_thpool -= 1; tq -- Viro