linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Riccardo Mancini <rickyman7@gmail.com>,
	Ian Rogers <irogers@google.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Mark Rutland <mark.rutland@arm.com>, Jiri Olsa <jolsa@redhat.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	linux-perf-users <linux-perf-users@vger.kernel.org>,
	Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
Subject: Re: [RFC PATCH v2 01/10] perf workqueue: threadpool creation and destruction
Date: Tue, 10 Aug 2021 17:24:00 -0300	[thread overview]
Message-ID: <YRLgYDKRUfwLSyHF@kernel.org> (raw)
In-Reply-To: <CAM9d7chuFG+cYPx34abvmciN0afUDqJ3uWo9Bsh-9jjLtQmWqQ@mail.gmail.com>

Em Tue, Aug 10, 2021 at 11:54:19AM -0700, Namhyung Kim escreveu:
> On Mon, Aug 9, 2021 at 3:30 AM Riccardo Mancini <rickyman7@gmail.com> 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

  reply	other threads:[~2021-08-10 20:24 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1627657061.git.rickyman7@gmail.com>
2021-07-30 15:34 ` [RFC PATCH v2 01/10] perf workqueue: threadpool creation and destruction Riccardo Mancini
2021-08-07  2:24   ` Namhyung Kim
2021-08-09 10:30     ` Riccardo Mancini
2021-08-10 18:54       ` Namhyung Kim
2021-08-10 20:24         ` Arnaldo Carvalho de Melo [this message]
2021-08-11 17:55           ` Riccardo Mancini
2021-07-30 15:34 ` [RFC PATCH v2 02/10] perf tests: add test for workqueue Riccardo Mancini
2021-07-30 15:34 ` [RFC PATCH v2 03/10] perf workqueue: add threadpool start and stop functions Riccardo Mancini
2021-08-07  2:43   ` Namhyung Kim
2021-08-09 10:35     ` Riccardo Mancini
2021-07-30 15:34 ` [RFC PATCH v2 04/10] perf workqueue: add threadpool execute and wait functions Riccardo Mancini
2021-08-07  2:56   ` Namhyung Kim
2021-07-30 15:34 ` [RFC PATCH v2 05/10] tools: add sparse context/locking annotations in compiler-types.h Riccardo Mancini
2021-07-30 15:34 ` [RFC PATCH v2 06/10] perf workqueue: introduce workqueue struct Riccardo Mancini
2021-08-09 12:04   ` Jiri Olsa
2021-07-30 15:34 ` [RFC PATCH v2 07/10] perf workqueue: implement worker thread and management Riccardo Mancini
2021-07-30 15:34 ` [RFC PATCH v2 08/10] perf workqueue: add queue_work and flush_workqueue functions Riccardo Mancini
2021-07-30 15:34 ` [RFC PATCH v2 09/10] perf workqueue: add utility to execute a for loop in parallel Riccardo Mancini
2021-07-30 15:34 ` [RFC PATCH v2 10/10] perf synthetic-events: use workqueue parallel_for Riccardo Mancini
2021-08-09 12:04   ` Jiri Olsa
2021-08-09 13:24     ` Riccardo Mancini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YRLgYDKRUfwLSyHF@kernel.org \
    --to=acme@kernel.org \
    --cc=alexey.v.bayduraev@linux.intel.com \
    --cc=irogers@google.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rickyman7@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).