Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1447680pxv; Fri, 16 Jul 2021 09:32:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLHCZ81RbZDq8RME0HwafVuTmGgpmwQpF1dMw7lN/qDaqyY4X9mBFytMxRSVDNrq5bP+Fx X-Received: by 2002:aa7:dd8d:: with SMTP id g13mr15867578edv.336.1626453126799; Fri, 16 Jul 2021 09:32:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626453126; cv=none; d=google.com; s=arc-20160816; b=PCNZlZ6n6bCxA8LJ9yel8yu31cQLXugLdb+stJno9WfhyLOGEeOuf2hOGRND4OR38C xDaKRBOE7VmAajrfaXXUPZyHYe7guGKu892a9v4lXrRWAtcssYUbK67kGRgWo/iU6zLg d8mDbJqD9HKEwT+htuxZGQiQqN1nOcrTipp8nJmtANNGoQUfCMObSjPSXECkFOs/8EJ4 FpB88RKo2jy3DDhO8m/dR8rY3C3QVVTxVlZSzVUBli6B8c18PQovIJMBADcgru6nU4du /txa6FceQub0Rmfy+7nh7hgunWB0duCFN/VpHjd4b52qNZLM+xPnLifIbKWKUQSdFHza Z9pg== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=wLiy0X0Lc4X/NhtO78LWVbtQuBWjiextArGsbfNgF5M=; b=KgtuEk+ImPBd3siIXKw6e31UPfenC8T66S86W5YCs+Sz6a4FasIfZtW9FSOHeNH2oN 0x18wvVYMwZg8nFmHLFZst6ilOi4c2JS2xbSMBQpeLZKanmgN6+ej+CzAVey1NS8xT5Z xSSQWQWKB+tEO2qgZ80DmXGYS5IcnPJ+/uMwQgUqeQfdiCEVPazgK9Tyer3duEBICNSk j0ms7hs4mf80htNuNJuAEnRdQtyUZ4MWNR8yMk8ujH5sJvX1Rb2qWNWHztXN8SOcChd+ M7v/bp532lTqTVxd59vtDP08FKh6OsgWxhdKRdh29I+SeqlpOA9Gnyy0XqULH76nGhxv 1eMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qsII8xGe; 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 cw17si11064782ejc.356.2021.07.16.09.31.30; Fri, 16 Jul 2021 09:32:06 -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=qsII8xGe; 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 S229597AbhGPQcQ (ORCPT + 99 others); Fri, 16 Jul 2021 12:32:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:43318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229574AbhGPQcN (ORCPT ); Fri, 16 Jul 2021 12:32:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 65EA261374; Fri, 16 Jul 2021 16:29:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626452958; bh=RPbljYHBe0gfkpEz6K8SRbVUNW/KwEPHQZ7dKTYAA7w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qsII8xGeR+hHV1JuAwt94vlkQ/IsqObycM+nj7FtuclDiYrMxXUGYVzuIsxapIuKR a7W9C2SUctE9ejQwN5Y4nJniB2M3jMd55IEXE9KEC9m9jEfh6AAeLzkBD/oQsdyK8T SlLdop5024U2B5gMTIxLQtEdNxMvFTAHvxDiIUd56ImF6zkMQC2HO/h+CvI1NC0Ryj PYwPfgntraC2GUOoi0ZTvD9EyL7pt/A4GHlpS2uGE3bS8INLlHhgnAFs11RCi/qPrj dIyQOuqWYMvVmtmS4P0kFW7sjMWwYVQMOaYonTNTeQtcz5CsLmwwG3px1T0OoXd1Hx qsQns2c6gPVPA== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 85C1F403F2; Fri, 16 Jul 2021 13:29:15 -0300 (-03) Date: Fri, 16 Jul 2021 13:29:15 -0300 From: Arnaldo Carvalho de Melo To: Riccardo Mancini Cc: Namhyung Kim , Ian Rogers , Peter Zijlstra , Ingo Molnar , Mark Rutland , Jiri Olsa , linux-kernel , linux-perf-users , Alexey Bayduraev Subject: Re: [RFC PATCH 03/10] perf workqueue: add threadpool start and stop functions Message-ID: References: <118c988358322b9daf69aeb98ff8986748b0dad2.1626177381.git.rickyman7@gmail.com> <5866e3456645659423030339f71f3461659ffe2d.camel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5866e3456645659423030339f71f3461659ffe2d.camel@gmail.com> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Fri, Jul 16, 2021 at 03:53:58PM +0200, Riccardo Mancini escreveu: > On Thu, 2021-07-15 at 16:48 -0700, Namhyung Kim wrote: > > On Tue, Jul 13, 2021 at 5:11 AM Riccardo Mancini wrote: > > > +++ b/tools/perf/util/workqueue/threadpool.c > > [SNIP] > > > +/** > > > + * wait_thread - receive ack from thread > > > + * > > > + * NB: call only from main thread! > > > + */ > > > +static int wait_thread(struct thread_struct *thread) > > > +{ > > > +?????? int res; > > > +?????? enum thread_msg msg = THREAD_MSG__UNDEFINED; > > > + > > > +?????? res = read(thread->pipes.from[0], &msg, sizeof(msg)); > > > +?????? if (res < 0) { > > Maybe it needs to handle -EINTR. > Its behaviour should be retry, right? > Since these reads are used multiple times in the code, maybe I'm better off > writing a wrapper function handling also EINTR. Take a look at readn(): tools/lib/perf/lib.c static ssize_t ion(bool is_read, int fd, void *buf, size_t n) { void *buf_start = buf; size_t left = n; while (left) { /* buf must be treated as const if !is_read. */ ssize_t ret = is_read ? read(fd, buf, left) : write(fd, buf, left); if (ret < 0 && errno == EINTR) continue; if (ret <= 0) return ret; left -= ret; buf += ret; } BUG_ON((size_t)(buf - buf_start) != n); return n; } /* * Read exactly 'n' bytes or return an error. */ ssize_t readn(int fd, void *buf, size_t n) { return ion(true, fd, buf, n); } - Arnaldo