Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp4659178pxt; Wed, 11 Aug 2021 10:57:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzL3p4GNwkhkYSGoecluhg+jCy+66u0PAyTvJGnqh85X+zKPFWow9qV91ASIyamC3ek7nqy X-Received: by 2002:a17:906:63ca:: with SMTP id u10mr4745870ejk.411.1628704675495; Wed, 11 Aug 2021 10:57:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628704675; cv=none; d=google.com; s=arc-20160816; b=Q5ZL5EQf5Y7WP2zD19/JmPCW3wMA0nhTuAm1vCy+Hb9WX7qXE/Uk7k2XHKuj3dcqVA 9U5zRLvqwZG79eJZx8hBkmayocIxa/TdjHfFZ9m7m8DLT1sE/IIOERWu+HADNAQWpr4U ghlXRJzGVZkHamSU/xwLtBePitAMJ5OOQfJ2y+84sn8ZYX6b+A+vExTXSyEcL4gkduZk ioBlVD5ugYN/JCptIm3hUcTUHXaikIm58kIIxQp3Txh63roQmjs43l2UQVY0m7IdWDkt /dpIOCp8+wqApzh7cEEVT0STaejeeIDPRyXwA1jq632DeNM6S7gm1T93unHXePmkFtER RxWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=C06n6gHg6YJWBZfHbRSueQw+91Fo4dmr2ttTA5pTkj0=; b=xAPm7P0bGQ1AKYabVQle4DG7ckfDivRIkkcaggs9fPmJbO/0voN9sCV141DzoE0ruB WAa86n2NMwV80Tc9O6uRkFSLWE52M2BBblKGfegcxuVMur9p02yeEpQDp1QxY+F0Ebss U+4pXr2bzTHjeb4rt0JsqelQf1L7mYJtBiSo565b40k23+7qWuCM0mIosKeUTHoTYqkl ESkt+VQDTuuxV9k/8JBWPdgjTNeKFBrYjyCBUOVgvvLmQqT3+wGYg6iwX1OYMm7kdOFB K5KbG/29S0Q2+8x2U+4/otYSdsl74pym+do5RDZ1J+MC7pUX6nFbb9Ge4eTmeSgHpyRo /ALg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=p+0G66gS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a4si3127864ejx.13.2021.08.11.10.57.31; Wed, 11 Aug 2021 10:57:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=p+0G66gS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230099AbhHKRz4 (ORCPT + 99 others); Wed, 11 Aug 2021 13:55:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230056AbhHKRzz (ORCPT ); Wed, 11 Aug 2021 13:55:55 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADD85C061765; Wed, 11 Aug 2021 10:55:31 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id q3so918090edt.5; Wed, 11 Aug 2021 10:55:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=C06n6gHg6YJWBZfHbRSueQw+91Fo4dmr2ttTA5pTkj0=; b=p+0G66gS4a8BosocdUTmtDslCZmCFHfvGnZwUTE2dmuP5+EFGK+VA7QbGpsGXTCeje 3A5zpYABjAeR9+ToVAa05A26vEpT7RVzmn5Wy0C5bgDfUMBUQm65tEWeT6zHpM+YfCKQ BYFwJ/mc8u7LC9ulgfry0tT9kqKv/9VfPQOU+UkibmSCl18+4OYJ++yLuLTZvUtE1K4+ 6iNwx/jaHJsej2fR3XfVuVnRhPw/5Pi7qNvzvFHvJuJQJTIc2qgYMhfEAkQ9Q0xm4SCV 0YHdvbGOOw6zl4+mF9YGtYJRXLyyeAiZWVqSx+6FtNc4j11/PcF+50qruX3ck3VTUdKy j0rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=C06n6gHg6YJWBZfHbRSueQw+91Fo4dmr2ttTA5pTkj0=; b=UVbbZ9hFamNzDvegGrGzNUUWsgrFfOFERgUL3mHEpj8iJCKM2Zy6E3ethfTu/a+Dkd Dnz/676VAkuf7OqU/TW4+VMrpW4di4j+rQWNRiEmha+6zfIGSqt763aB70qZsMR3cP8T 6hBsfitLMCV2m6BrK3LnOnDH02I+yqXE7SNUl7d8PordYyldO9aq1qbZTkhCPDpyzKr+ i9aukf1Ddxu/LQXC0nlYL7mVwk9zNB6Lme07YuXQSLRo0GN8RsXACugSuLRue8IogpbJ MvMfMPRCINEQ7ar0xdzg5P3SZomI/1aCQleou1F1ZScedmijo1D3vFmXoH6IXi6jIuDl PrQQ== X-Gm-Message-State: AOAM530B6oe4D1xgx+S8h7Q+mtxt3kECnOrR+fHnWopa9/auKlvW2u8B FiXOzCrBkABAZcs0XXLzZgE= X-Received: by 2002:a05:6402:11c6:: with SMTP id j6mr76774edw.349.1628704530193; Wed, 11 Aug 2021 10:55:30 -0700 (PDT) Received: from [172.16.0.82] (nat-allievi.sssup.it. [193.205.81.9]) by smtp.gmail.com with ESMTPSA id g26sm40239ejr.48.2021.08.11.10.55.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Aug 2021 10:55:29 -0700 (PDT) Message-ID: <4941e4a6d898a4545ff319b6b74442e18ca8025a.camel@gmail.com> Subject: Re: [RFC PATCH v2 01/10] perf workqueue: threadpool creation and destruction From: Riccardo Mancini To: Arnaldo Carvalho de Melo , Namhyung Kim Cc: Ian Rogers , Peter Zijlstra , Ingo Molnar , Mark Rutland , Jiri Olsa , linux-kernel , linux-perf-users , Alexey Bayduraev Date: Wed, 11 Aug 2021 19:55:27 +0200 In-Reply-To: References: <4f0cd6c8e77c0b4f4d4b8d553a7032757b976e61.1627657061.git.rickyman7@gmail.com> <25278c08762593a5b0bd1873f6c0745c7ad97016.camel@gmail.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.40.3 (3.40.3-1.fc34) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2021-08-10 at 17:24 -0300, Arnaldo Carvalho de Melo wrote: > Em Tue, Aug 10, 2021 at 11:54:19AM -0700, Namhyung Kim escreveu: > > On Mon, Aug 9, 2021 at 3:30 AM Riccardo Mancini wrote: > > > On Fri, 2021-08-06 at 19:24 -0700, Namhyung Kim wrote: > > > > > +/** > > > > > + * threadpool__strerror - print message regarding given @err in @pool > > > > > + * > > > > > + * Buffer size should be at least THREADPOOL_STRERR_BUFSIZE bytes. > > > > > + */ > > > > > +int threadpool__strerror(struct threadpool *pool __maybe_unused, int > > > > > err, > > > > > char *buf, size_t size) > > > > > +{ > > > > > +       char sbuf[STRERR_BUFSIZE], *emsg; > > > > > + > > > > > +       emsg = str_error_r(err, sbuf, sizeof(sbuf)); > > > > > +       return scnprintf(buf, size, "Error: %s.\n", emsg); > > > > > +} > > > > > + > > > > > +/** > > > > > + * threadpool__new_strerror - print message regarding @err_ptr > > > > > + * > > > > > + * Buffer size should be at least THREADPOOL_STRERR_BUFSIZE bytes. > > > > > + */ > > > > > +int threadpool__new_strerror(struct threadpool *err_ptr, char *buf, > > > > > size_t > > > > > size) > > > > > +{ > > > > > +       return threadpool__strerror(err_ptr, PTR_ERR(err_ptr), buf, > > > > > size); > > > > > +} > > > > > Why two different functions? > > > > Since when new fails you don't have a err number, just an err_ptr so it's > > > not > > > very clear how to call threadpool__strerror. Therefore I made a wrapper to > > > remove any ambiguity. > > > > What do you mean by "when new fails"? > > I think 'new' is 'constructor', i.e. something__new() returns a newly > created object and this not an error number, so he uses ERR_PTR() and > then he needs to pass it to the 'strerror' specific to the > threadpool__new, which will use PTR_ERR() to get an integer, and then > map that to a proper error string, right? Correct. threadpool__new_strerror is not really needed since one could use threadpool__strerror directly, but then I would need to handle all possible ways it could be called (e.g. (NULL, PTR_ERR(err_ptr)), (err_ptr, 0), (err_ptr, PTR_ERR(err_ptr)), so I thought it was better to just provide a strerror that only took the err_ptr. Maybe I can provide it as an inline in the header, or as a macro. Riccardo > > - Arnaldo