Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp4697327pxb; Tue, 31 Aug 2021 11:03:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqoq5/BoelC5uMd5IhlCZGmgbc73o+p797IFO4urPRXu1E6RZENEVavYhBWC0MONUyRHGD X-Received: by 2002:a17:906:fcda:: with SMTP id qx26mr32124818ejb.121.1630433018417; Tue, 31 Aug 2021 11:03:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630433018; cv=none; d=google.com; s=arc-20160816; b=zpB6Rb0Qmvap99efIrPSLc6p7FW90OvOruEZ0F2XSkkhjQYWVRODV4qEuJ16bA8781 EkCI6AHz+j0+lkbUc7hyknaKF2m7Ov4UFSFFfCZk45773k0Z+cCCQ2zhZ8vsZbDiL5Pz g7XVFxFd1InBGhvLuINcJwpj4GQq9eUqXEijs/fLJEr+c5UonJUd/kfHV2JdYYqNHHhJ anHlCCe2kHlc8BHl/tIoIJYE6eRoyYnukvDksU20YGV/tczLj6PUfwwhQho8O6SaXSGA inTHoPZWu6A/tAyr5m9GX2j4foZ7I/IzCv2Upif+v0cmuSm8vtQ7QGwYxqqOxn/MDPUe z3YA== 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=2+L+wB0fnPlt/CRaJbJJjyyQujawdtG2naZwB/HENfw=; b=XfrIRU4u/B51z/RnuHvRfhhgak6g8ScPT7dY72lByB8vhFwEFcxeH5vpzBRCbe6TsU K92b+Hw3Q1fB9bKel+5NMf8HtnX4DJIS48iuYakSARy/uq6o1s7XVnNW+ddowvvcNuad cNAFUik3E5hCIMWX3B/xwE+cfcThz07kqUPNZQBSzuN13pOvLtc9FWNEtFMQj1kwbMPy RHfM8AQ2SgDGbOQpkQBgNZde+Uu/ORirXoLBmR+4Exn0sz9va4ZjyNoDj3m55TAhu2Dg jbF1HM1QX8CzPFzhw1p8w+dKwOicB2uXuhx6opeWTXbGYzRqZjhGaADcnUhfQaD69V0W 6JPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VK0imM80; 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 qb1si19002827ejc.35.2021.08.31.11.03.13; Tue, 31 Aug 2021 11:03:38 -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=VK0imM80; 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 S239795AbhHaQOS (ORCPT + 99 others); Tue, 31 Aug 2021 12:14:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239823AbhHaQOR (ORCPT ); Tue, 31 Aug 2021 12:14:17 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12F1AC061575; Tue, 31 Aug 2021 09:13:22 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id h9so40014038ejs.4; Tue, 31 Aug 2021 09:13:21 -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=2+L+wB0fnPlt/CRaJbJJjyyQujawdtG2naZwB/HENfw=; b=VK0imM80Bz7slqaDcXPMpShGFFNKBKHZG1KUYYcIno/WBJitmRfAE6N/5EMSNggkff YW1ImdRK5HjNK+PrOz6h4tWU6hJo938HjarBrxuTr+uZMImqUJpX8vQpPQphw82SRlJd 1ddSt3GA+UXBnGfCYWuVRizpUDEjZP48ogvi8cLxGpYopC/sgsi9yRQJhdor1x4ehQ3Y bHNrEixqaZeh7m+RE28047S3a7X2deKMZ1dQFBLV234ncl73CWo1she6w7v6VxvZ4aF3 J2dLWeABu0EnoEdMTl6dMjqPVkr9/dwanfNAx+tNT9CXDyh7k0dOXxsMyDL3/i55Y2Ai +Y1Q== 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=2+L+wB0fnPlt/CRaJbJJjyyQujawdtG2naZwB/HENfw=; b=Zvp1+CCWPiFklnYeD/3mdZyPNeGTGweTfSDNW+E0ldZe6WqEayTP3PSG+791fk8se5 V/z7WFiOOMIjux3MxSztEkv6uzcI263pkWZqNpwmo7l1T6lm7WKQFZ7kszWAY2GqdVRe WiNSTPMUyRWuQFzP7NC+kNQFsie2Xgcceq2BIw8WO/f+Q7ozV2jfKF3NHkt7sOIqlxVo SEGe5ynNzRQoBdwXjc3PyuezHizBce8hks4iJDEOZ9lhWHdmR8u76u6tM5XCb6KgMCX/ mQAHLhOwteaA23Jp+oyodIQxvjyKI5f9bWscrKU6zOADzPZd0sOZU/oiNXt/nDWTYzPl U/SQ== X-Gm-Message-State: AOAM532bDJkPyHIK9M1jlfKjJo0JkLIKCEN/OdLoD4Tu0hNJ9BM/0qEk HdTGikqk6IsdJ5JxczKs1cE= X-Received: by 2002:a17:906:ce3a:: with SMTP id sd26mr12260355ejb.227.1630426400410; Tue, 31 Aug 2021 09:13:20 -0700 (PDT) Received: from ?IPv6:2001:b07:6456:fd99:ced0:db1c:53e1:191e? ([2001:b07:6456:fd99:ced0:db1c:53e1:191e]) by smtp.gmail.com with ESMTPSA id jz16sm6577903ejc.34.2021.08.31.09.13.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Aug 2021 09:13:20 -0700 (PDT) Message-ID: <7c3d2688a1544eb5ea963cd2b07a2ff03d328c4a.camel@gmail.com> Subject: Re: [RFC PATCH v3 06/15] perf workqueue: introduce workqueue struct From: Riccardo Mancini To: Namhyung Kim Cc: Arnaldo Carvalho de Melo , Ian Rogers , Peter Zijlstra , Ingo Molnar , Mark Rutland , Jiri Olsa , linux-kernel , linux-perf-users , Alexey Bayduraev Date: Tue, 31 Aug 2021 18:13:18 +0200 In-Reply-To: References: <9dee672538967a3cf7e82ef194ebccc709b1af41.1629454773.git.rickyman7@gmail.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.40.4 (3.40.4-1.fc34) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Namhyung, thanks again for taking your time to review. On Tue, 2021-08-24 at 12:27 -0700, Namhyung Kim wrote: > Hi Riccardo, > > On Fri, Aug 20, 2021 at 3:54 AM Riccardo Mancini wrote: > > +/** > > + * workqueue_strerror - print message regarding lastest error in @wq > > + * > > + * Buffer size should be at least WORKQUEUE_STRERR_BUFSIZE bytes. > > + */ > > +int workqueue_strerror(struct workqueue_struct *wq, int err, char *buf, > > size_t size) > > +{ > > +       int ret; > > +       char sbuf[THREADPOOL_STRERR_BUFSIZE], *emsg; > > +       const char *errno_str; > > + > > +       errno_str = workqueue_errno_str[-err-WORKQUEUE_ERROR__OFFSET]; > > It seems easy to crash with an invalid err argument. Yup, I should add a check in the next version. > > > + > > +       switch (err) { > > +       case -WORKQUEUE_ERROR__POOLNEW: > > +       case -WORKQUEUE_ERROR__POOLEXE: > > +       case -WORKQUEUE_ERROR__POOLSTOP: > > +       case -WORKQUEUE_ERROR__POOLSTARTTHREAD: > > +               if (IS_ERR_OR_NULL(wq)) > > +                       return scnprintf(buf, size, "%s: unknown.\n", > > +                               errno_str); > > + > > +               ret = threadpool__strerror(wq->pool, wq->pool_errno, sbuf, > > sizeof(sbuf)); > > +               if (ret < 0) > > +                       return ret; > > +               return scnprintf(buf, size, "%s: %s.\n", errno_str, sbuf); > > +       case -WORKQUEUE_ERROR__WRITEPIPE: > > +       case -WORKQUEUE_ERROR__READPIPE: > > +               emsg = str_error_r(errno, sbuf, sizeof(sbuf)); > > > This means the errno should be kept before calling this, right? Yeah, I should make sure to preserve it, I think it's done this way in some other functions. Otherwise, I can save it in a struct attribute, which is maybe simpler. > > > +               return scnprintf(buf, size, "%s: %s.\n", errno_str, emsg); > > +       case -WORKQUEUE_ERROR__INVALIDMSG: > > +               return scnprintf(buf, size, "%s.\n", errno_str); > > +       default: > > +               emsg = str_error_r(err, sbuf, sizeof(sbuf)); > > +               return scnprintf(buf, size, "Error: %s", emsg); > > Newline at the end? Forgot it, thanks! Riccardo > > Thanks, > Namhyung > > > > +       } > > +} > > +