Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2535736rdb; Mon, 5 Feb 2024 09:23:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IESK6+FwCvn4dydKUzLB+xSn2ACbMgSahK7ZCF0X4bJBCj7P4+xSu+f9fX1JW0+6AUtJgL2 X-Received: by 2002:a17:903:2442:b0:1d9:1cb5:558b with SMTP id l2-20020a170903244200b001d91cb5558bmr221040pls.15.1707153792212; Mon, 05 Feb 2024 09:23:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707153792; cv=pass; d=google.com; s=arc-20160816; b=rfzBwi2pJ3RahNgoW59oF4hQzerx/5j+P+hATpWRFScnlmH32C+KgQCgZ5BDTntbms XTyElpqNksvq/m+Zys2Kbyx/o624m2/Jc4E/E9kabjBzjNXQDZxBc4XkJjJFtPt00xeP ePtZyp53gJDKFuAEpF6jYqjQFwCHQognIcUH6DmtA4eOoo38CL+ghKo/L34cqrV3aRSz ibUm0CB4Z/58fNEf0B/ea/zuRk2o1uImC7kfZ1wdGxTkek/PmRXOXLJVF+ZFoIlfsIIJ /FiDWRaKqnU74p3hci2Ff0MrblJdpwq0wR7SzK3LpSIJMnOdUFGpp9nVgPgpVWRwz+2d OJ2A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=U2Wb1oqYdTOPyIfTj8k18sBz6J4vMMDQXogO+wpB9PY=; fh=UH8jPIGO9W9rY6KI2A/sK4wVkbm8TvV2xM4d/Dsw0Go=; b=P7PO8nduhfD3Tj1uym0/Yts6SEkks0fgkbaznWhZQEw229tzcCSpxbzAuv4ZRxkUxR 8aqBriz4f9vuQjyfFnZxLd6EiaAruS1AW1MJcsDiieIwXMxkzHY2daW03UAYAujA5w01 l7D7MWVUqiSPfctDTxErsOE5SIrrpfzY2Uzjd0oOEZm5+w6cSvG6KWd7uI19T0Tw52R5 W3x5ZOHyPYCGMERbhabxR36NAuL+9yeQRIPmq7VSCYl1y1tKyQWM+2p8QfRb0CaHPD9t b8cze0VdYOpAIl30VkpoQzKo4oXGIMIDDVoZegLLZHOfPe9xcg4cSM+u+ULZ/J++gGqJ Mexg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lhzRt8cu; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-53074-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53074-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=1; AJvYcCWbSphl8s2RDoi/1JizWLHnZOH8UrnegDko2aMhgmL6RfEqF5Dk6br2ckl3trgwoGuMaTThZhrWPpbagVaFqRlu9BVJN/VZy6/g/YY/UA== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id t14-20020a170902e84e00b001d791ce5b52si142063plg.209.2024.02.05.09.23.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 09:23:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53074-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lhzRt8cu; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-53074-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53074-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 9928DB21A54 for ; Mon, 5 Feb 2024 17:13:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D203840BF2; Mon, 5 Feb 2024 17:13:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lhzRt8cu" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 F383544C64; Mon, 5 Feb 2024 17:13:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707153229; cv=none; b=sAsyZ6dPE5m128x16WZnEGzO+Elk60+mMs5/+7DopBMr1rCX1WbJGci3qfG+y7ff/nzynGlncniO5eMDhGBk6D3ZMxSDdOMiU+qVOMq5aV2qSq0U6aiO1pIqUEoISW8afI6l3RWI93zCVbuNcg79i019G0k1Or8kwLAUYDkNAG4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707153229; c=relaxed/simple; bh=GUIw1Clt8W7XheqxN9DyFdV0X+bok90f0WYN3AWZKu8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=PDdR5AEKyRHRiEc1wz2FLkmU8Q9JniCJPGgtAcAyzLeh3yD+C9aKT5hySraitLHAIAfQ4K8ZQ0gpb13YlmKzACrQNyzhEOrF+H4RkKEm6GohpRE9LD+qWfWJoX0ZIRS/k5eruav2pSOj6cg4CkspGKcTKK8PsiW4s7OLiYp7Dek= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=lhzRt8cu; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707153227; x=1738689227; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=GUIw1Clt8W7XheqxN9DyFdV0X+bok90f0WYN3AWZKu8=; b=lhzRt8cuNDsKSapgNoglOuRKCfmubB5v6CA7SCvTfVjwWYyTO5msEJfO lgqnVuccbaFsLNKaEFLTR4jBUOjwUM/J3FuC23vgvZKG/58d3bRNwZjPg JKhtrNT8gxnzQLIZZE/Ff2vtudoINn7rAgWX250oDbgxHwu6BEDBJrUrC OINJ6xJSwL88p8sqJritH/iSHpcncjHN1ibSCTdk+6tutRwXtAGvBwjkr r3bwd9s72ib1aPkrPRQOKnW4dqdJnfN8Pbv2+YSUqjINBNxWxCJ0Xd1Ci 3IjepLwRRdV1ltX6QK5LTZ4CD2KAfs197PoIoWsjxrn0hRmRGG6w826jS g==; X-IronPort-AV: E=McAfee;i="6600,9927,10975"; a="11210870" X-IronPort-AV: E=Sophos;i="6.05,245,1701158400"; d="scan'208";a="11210870" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2024 09:13:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10975"; a="909345630" X-IronPort-AV: E=Sophos;i="6.05,245,1701158400"; d="scan'208";a="909345630" Received: from djiang5-mobl3.amr.corp.intel.com (HELO [10.246.112.181]) ([10.246.112.181]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2024 09:13:45 -0800 Message-ID: <14b212a4-e7b5-494a-8665-06842b2c7cbf@intel.com> Date: Mon, 5 Feb 2024 10:13:31 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2 v2] cxl/region: Use cond_guard() in show_targetN() Content-Language: en-US To: "Fabio M. De Francesco" , Peter Zijlstra , Dan Williams , linux-kernel@vger.kernel.org Cc: linux-cxl@vger.kernel.org, Ingo Molnar , Jonathan Cameron , Ira Weiny References: <20240205142613.23914-1-fabio.maria.de.francesco@linux.intel.com> <20240205142613.23914-3-fabio.maria.de.francesco@linux.intel.com> From: Dave Jiang In-Reply-To: <20240205142613.23914-3-fabio.maria.de.francesco@linux.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2/5/24 7:26 AM, Fabio M. De Francesco wrote: > Use cond_guard() in show_target() to not open code an up_read() in an 'out' > block. If the down_read_interruptible() fails, the statement passed to the > second argument of cond_guard() returns -EINTR. > > Cc: Peter Zijlstra > Suggested-by: Dan Williams > Suggested-by: Ira Weiny > Reviewed-by: Jonathan Cameron > Signed-off-by: Fabio M. De Francesco > --- > drivers/cxl/core/region.c | 16 ++++------------ > 1 file changed, 4 insertions(+), 12 deletions(-) > > diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c > index 0f05692bfec3..bd3236786a25 100644 > --- a/drivers/cxl/core/region.c > +++ b/drivers/cxl/core/region.c > @@ -666,28 +666,20 @@ static size_t show_targetN(struct cxl_region *cxlr, char *buf, int pos) > { > struct cxl_region_params *p = &cxlr->params; > struct cxl_endpoint_decoder *cxled; > - int rc; > > - rc = down_read_interruptible(&cxl_region_rwsem); > - if (rc) > - return rc; > + cond_guard(rwsem_read_intr, return -EINTR, &cxl_region_rwsem); > > if (pos >= p->interleave_ways) { > dev_dbg(&cxlr->dev, "position %d out of range %d\n", pos, > p->interleave_ways); > - rc = -ENXIO; > - goto out; > + return -ENXIO; > } > > cxled = p->targets[pos]; > if (!cxled) > - rc = sysfs_emit(buf, "\n"); > + return sysfs_emit(buf, "\n"); > else This else isn't needed because your if statement above returns. I think if you run checkpatch it should've flagged this. > - rc = sysfs_emit(buf, "%s\n", dev_name(&cxled->cxld.dev)); > -out: > - up_read(&cxl_region_rwsem); > - > - return rc; > + return sysfs_emit(buf, "%s\n", dev_name(&cxled->cxld.dev)); > } > > static int match_free_decoder(struct device *dev, void *data)