Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3871252pxt; Tue, 10 Aug 2021 13:26:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsK8SG+IQYOzkrp6XvT8Osvzm48TIO8V1D3hqeIQuXDG87Ewx3WInRg/lLNrDt6vpUE8/r X-Received: by 2002:a05:6e02:688:: with SMTP id o8mr404585ils.182.1628627175300; Tue, 10 Aug 2021 13:26:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628627175; cv=none; d=google.com; s=arc-20160816; b=PAP5gFy5sW5biV59jeQ/5VE4wJ7cMCTiZ5ldbviSJOM//o1xoPCMdXL6NYYqSdbQep 0T9TAyJtCnKhlY0dR9ZSKYDeK5Hf8E8msJFiMVCw9LIITB2DGainGMb+uY3m/4tgcNYv n3RL6wMdkwkfKig/kSXFpGfdtJzTrAD3GOFG01SLwB4xTyjP8P5Z2S8raAkjVw/S3qb/ pWvIkzGSzuH1M9P6vr9RbKpqY/lxU7UEWN5gQ5Msy0Ei8glf4duLzt01lALiwf11SZA9 mmzG2EKPxNDBzMzCH7RZ65R+9jxn/UtmR/JL1Q3q9/X3P/Qn+c/GoHRShDDVaYY7iY4y ILqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=JqKjO9mc2D9nhwFc0xmdvxDAo20XYvSjhC9dAXg+lI8=; b=ftD21aL96RbmsrTc0icn6lpPmSxJ85FHPtGS9oQUDJcQLz9zjh4Bec0N8Z2AWq79gT o+X569va+VkykrJZbebkHYXxs/XTRGq/46PCG8uhxxfbSYekdD5j8sw3KsEjnVJZql2i WfuYE44doJGWr68oI8b1XcLnjN/k3wpPCvaCq2l0X5WU1M7GnRoasdxsVpE/ynmW9rvH //yxLGBY7dLT05eSbzYYMTDG6gNbqck6o2N+ZYd9nKBYnUFHgZqhbjlDsR3xjYthtKAO EfbCPWW+n7blVLdqw6QKtZJoG5sTb4sdtxDBO24jqnX0AEjdIwilz0oP/JvFmxlo/wSd 0fgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KvIco6IU; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d7si20774892iop.31.2021.08.10.13.26.02; Tue, 10 Aug 2021 13:26:15 -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=@kernel.org header.s=k20201202 header.b=KvIco6IU; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233044AbhHJUY1 (ORCPT + 99 others); Tue, 10 Aug 2021 16:24:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:38666 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233151AbhHJUYZ (ORCPT ); Tue, 10 Aug 2021 16:24:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4F71560F94; Tue, 10 Aug 2021 20:24:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628627043; bh=yYKQhPsS+9XZipxTRUgp1k54tHTu9xHb9DIX7R3d+pY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KvIco6IUfRtZjwqogT+o2n99HoFNKdLDyrDW0Q08kPes8b1My8dgPuY833OBukfsI 8TtNj1tdLGsca7SFbeKeTUHA+TrVlyUrmkDPwZ2Hz6PeAMR6sHQHakLCScxL/CdxYq nWrKpqetpVB+mKrSnGHPe+zf2VHA0S7H4/xWAr5TfDVreT8KJT+wUPsMuLba9yxHAS pujmXkrNPkXdjDCiH9Dfv7KUn9AOMADELg0i+NLvUgHY4AhCXgcX577SZTPVZyMq6C ldfHb9pLdNXqAqdlJeNaUsyeArfH727Q1T6TCA6CUCR394EhFUrybbZowFVW6FYAIb D0jx8GZzA1VOg== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id CB47F403F2; Tue, 10 Aug 2021 17:24:00 -0300 (-03) Date: Tue, 10 Aug 2021 17:24:00 -0300 From: Arnaldo Carvalho de Melo To: Namhyung Kim Cc: Riccardo Mancini , Ian Rogers , Peter Zijlstra , Ingo Molnar , Mark Rutland , Jiri Olsa , linux-kernel , linux-perf-users , Alexey Bayduraev Subject: Re: [RFC PATCH v2 01/10] perf workqueue: threadpool creation and destruction Message-ID: References: <4f0cd6c8e77c0b4f4d4b8d553a7032757b976e61.1627657061.git.rickyman7@gmail.com> <25278c08762593a5b0bd1873f6c0745c7ad97016.camel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? - Arnaldo