Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp105353rdb; Thu, 1 Feb 2024 03:36:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IF2oorfXPZ2i+dctLpxz360+6SfbSnwvPwD/0/c98xWZu4HVqA4W7Uu3FYTR7a3PdxtyNr+ X-Received: by 2002:ac8:570a:0:b0:42b:f5a6:2ae1 with SMTP id 10-20020ac8570a000000b0042bf5a62ae1mr1390452qtw.45.1706787400750; Thu, 01 Feb 2024 03:36:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706787400; cv=pass; d=google.com; s=arc-20160816; b=xMgwR35S+yFCoWikIBEFd9s2/PSocgq+9Fc4yt/+qTTm38HkfRRdD7iwzMy7vExBQx PhhYzluVgzKt1cQwxy7KJ8z5Pv5vf/GJmzzNJbnKh4+Ne4V1yDqGZp5Nm9fSsZcVRvuN +57kevzBCNNGLhgRZJ0GUxm0WmEr7sggRkcQPENdnrPv0nckqN+SodH4Ijaxqg54/Yj0 4/+eb/UMJ5sTsf4VtySH4aA2o0AITNFVMfLskGpzT4oeK/z8PVO6WTXaJnbz1KJ3cOks HbGllB/KQUleptgU0JIBxA1SNSO5FQJQADbog3OLqPgXY8pwS7yCIfm+d3gX/87jx31t V59w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:organization:references :in-reply-to:message-id:subject:cc:to:from:date; bh=OcfWhLq3xiRsusjVe8K7ijmalxSVHv04DzA6/mCcV40=; fh=a8lSiZ6HoShXv5jLsRuQ/pg5+pCN2U3AW0JnfJOZ7/c=; b=EERTo0dX/pMcAiRi8/61FHIImv4PjHE0EgtCYOu5ix7tY4vV7o3r8jwJNLI95ZkWDE HG60z95fz18tKCMRJf+V5Atv1xiXkG+ISTpTrwIAJ/3LzvP7kAVmPgYcbuhGwhDR1nbk LZXoPAneQc2EyrXuyAKfpCnC9+CXUTIBb3R20lJ0SnLaWL3nE7EHy4HsD1mDte92tfue At9rLpPAxiI7jYny7uBy+wwBjQ5Otj9JgbgZjJvDwxWDv7spW+PRUUW78ZgC+mt3PzS5 Slz9bZHO4jMLtnYLilBMCMbExbEj7vz/QJh2liLtD/4DJJNHxqDzq8D/r9gwfiYbbQsb jAMg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-48019-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48019-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com X-Forwarded-Encrypted: i=1; AJvYcCWziR2755k0BBpBXMaUKN64OeoEvDmslu7MPuI/y48NYEWMnTpVcRQcE624EGdyUpObNuZ85L0ZziWNSMAL8soQm/0TBPfV+gIBqXR4rw== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id r17-20020ac85c91000000b0042bf9af20fdsi361203qta.11.2024.02.01.03.36.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 03:36:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48019-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-48019-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48019-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7C7CF1C243EF for ; Thu, 1 Feb 2024 11:36:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1B02115D5AD; Thu, 1 Feb 2024 11:36:20 +0000 (UTC) Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05BA915B964; Thu, 1 Feb 2024 11:36:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706787379; cv=none; b=a4cNCdwq6m2/IRN7X0nCuY2pNAsdTfVTa1CmJLrK2XbNIZuxo6O6EtVwgTPaYXJ+juuyPxk+Otn5LGR2Oq035W/DyXS+svBi70TLwjYdpKEU7amkV0nY4ZNXBmIt0bbR9KZBT3Ka7IrI6F9uBP+QHU3CdOmE5yR5c9RobWP+Tyo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706787379; c=relaxed/simple; bh=jGa42X+BFB0gekur+doHwNmJpCnbHR5W4fMjgpjmq+0=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fHBcW74SdqqR4u21vaHCHolgfoLGxVOsx/o1sjlZ6eRPsRIWVooOFnHQUijVSUmrUoh2uxf3DYEuYWmMSatC0G4V1hnJpPiro32kfGSzI12lMY02VhtzlwsmQtPGEf7Qghe32iRmyHqWDLTVvuc/M3QPpd5VasN9wejCKA0uxtg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4TQcGD01SGz6JBVN; Thu, 1 Feb 2024 19:32:52 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id 6BD2C1400D1; Thu, 1 Feb 2024 19:36:14 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 1 Feb 2024 11:36:13 +0000 Date: Thu, 1 Feb 2024 11:36:12 +0000 From: Jonathan Cameron To: "Fabio M. De Francesco" CC: Peter Zijlstra , , , Ingo Molnar , , Ira Weiny Subject: Re: [RFC PATCH v3] cleanup: Add cond_guard() to conditional guards Message-ID: <20240201113612.00001d90@Huawei.com> In-Reply-To: <1785013.VLH7GnMWUR@fdefranc-mobl3> References: <20240131134108.423258-1-fabio.maria.de.francesco@linux.intel.com> <6168759.DvuYhMxLoT@fdefranc-mobl3> <65baefec49c1a_4e7f52946b@dwillia2-xfh.jf.intel.com.notmuch> <1785013.VLH7GnMWUR@fdefranc-mobl3> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: lhrpeml100005.china.huawei.com (7.191.160.25) To lhrpeml500005.china.huawei.com (7.191.163.240) On Thu, 01 Feb 2024 09:16:59 +0100 "Fabio M. De Francesco" wrote: > On Thursday, 1 February 2024 02:12:12 CET Dan Williams wrote: > > Fabio M. De Francesco wrote: > > > I just noticed that this is not the final version. It misses a semicolon. > > > Please discard this v3. I'm sending v4. > > > > Ok, but do please copy the aspect of scoped_conf_guard() to take a > > "_fail" statement argument. Passing a return code collector variable by > > reference just feels a bit too magical. I like the explicitness of > > passing the statement directly. > > I had introduced a bug in my tests that made me see failures when there were > not. Now I fixed it and tests don't fail. > > I'm sending a new version that passes the return variable directly, not as a > reference, similar but not equal to: > > cond_guard(..., rc, -EINTR, ...); > > Actually, I'm doing this: > > cond_guard(..., rc, 0, -EINTR, ...); Can we not works some magic to do. cond_guard(..., return -EINTR, ...) and not have an rc at all if we don't want to. Something like #define cond_guard(_name, _fail, args...) \ CLASS(_name, scope)(args); \ if (!__guard_ptr(_name)(&scope)) _fail Completely untested so I'm probably missing some subtleties. Jonathan > > I'm not passing 'rc = -EINTR' because I want to take into account the > possibility that rc contains values different than 0 from previous assignments. > I'm passing rc, so that the macro can assign either a success code or a > failure error to this variable. Any value from previous assignments must be > always overwritten: > > #define cond_guard(_name, _ret, _scs, _err, args...) \ > CLASS(_name, scope)(args); \ > if (!__guard_ptr(_name)(&scope)) _ret = _err; \ > else _ret = _scs; > > I should have seen long ago that my tests were failing because of a missing > 'else' when passing a statement in 'cond_guard(..., rc = -EINTR, ...);'. It > had nothing to do with how to pass 'rc'. Sorry for that confusion. > > Fabio > > Fabio > > >