Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp530358rdb; Thu, 22 Feb 2024 10:57:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWVDHffOfdfEssKWuNX5/3t5MhJR53SrCSPWa/oZIGR2xq6jbUdYRXCmKkkQnnv6RiUjBWhApmVolIg/eeTHSK8WweB9Tqbgd83Kk2HgA== X-Google-Smtp-Source: AGHT+IHN9AIggNvvHLdeOeve2aI0UOjKzj8eP/OP4P4b9rVQSzDHiJgFgsb08jgqlns2F/tgoHVt X-Received: by 2002:a17:902:e848:b0:1db:c84c:3549 with SMTP id t8-20020a170902e84800b001dbc84c3549mr18810449plg.11.1708628279298; Thu, 22 Feb 2024 10:57:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708628279; cv=pass; d=google.com; s=arc-20160816; b=rRlRCOLNsLMj2gOBaKOvdswUiI2+MDx5L8+hUw4/7HpKpetVYIQxnUZNsc6m8BfmrW j1q+M9MYit01zdpRoT9SIeBItwTc5fhSKnLiLsvUegOXt3mbgmnbnUTgbnojaXBo72ee hAOonMn6Pu+GfvYLXndDskTwJBLkaRQuAvf1d4bDK2vgmpiGyjG1NxIoMvCDz1R6dM7K nNUCbK758M425X2Tw17O26ZJKZ7BfaZjklH4hXy8KFhKDq1MFcMhstBgNYQAxXCiw+nY HBPgG0CGxVYI2KVYHtQtRWFGJO7bHf5K6k/7fMiuZWQCq2AD4W3ZESoaR/9Vf6CU8aNl 3iwg== 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=4sGq3QLO/RDazewhPe4/NFlUurGIq7INfaGJ/jTa0io=; fh=uVP7CRzX3dTb6bgxhygkSs7eS933MphxQdjP/8UEdEM=; b=NcAr8JOMAkLB4SZFVuB9JOFcbm0AgVeniCdbdLYre8wlpyVT58SVpnijZHVxQeZwzO sg+T5GOHjHonDHjcQ4WKVv/21OmAeD6BwBR1/VgrU4QMf5b/UYi6375rbwUS1R6wy3FA E3GbjIMTywWk/f/vy5m6Ou2Ow5Cj/4rykidWWhwo2DNMPMaxtaS3FZgdF5gF+ZNc9nB9 v4toP7DazOcH/+Ff5ZkxZkUyrfcZUXyUuBruIYt59Ejxb3mtNtNyPqBMhYPvUV28wYQl Ljqn9vaam/8RlaWf5+PbSVf2Hq0YGLGAC9kmh0vGYWZH7VmWYyHWJlZplo0tW/FSrb6p R4wg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OpFf+2VA; 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-77139-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77139-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id q6-20020a170902eb8600b001db8a5ea0a7si10720817plg.423.2024.02.22.10.57.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:57:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77139-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OpFf+2VA; 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-77139-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77139-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 556CEB241B5 for ; Thu, 22 Feb 2024 18:38:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8734D73F08; Thu, 22 Feb 2024 18:27:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="OpFf+2VA" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (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 E27196E61C; Thu, 22 Feb 2024 18:27:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708626459; cv=none; b=DTAu/TIVce5VfzL8KoJSHUt8PeAp/FOd++TjX0+OiwoB+vQjdgWFieMt3IyQAK+l/KnsakSJIGpoKjDqBJ05Rceouw029xBbqV9woVAQlL4+Up5PghHGkyfLM4dOvllB31plTb0WMQPOyl08yoSZ18odI7h3R+B9/6vEKNkCgWM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708626459; c=relaxed/simple; bh=xM/QGOiRYmmtfXJfmB0d8tNDu2LXbkjtP1X6XvDL9RM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=c0XTaXcgSZ5K6gNrf91f+VwVrUSICFW28lAiMhuxlSMM8qa5L2RUi8/HNdx3zMm8i4X3CH8Eafm9AZGmnEvpbcMEFiEpsCanoK6SrGsdSaxWHbim/sABTLwe+1ExSdbtowZkSWoADBJfnu6bedQ0Q3vpgCHRzs6OKfGk+YBsU4s= 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=OpFf+2VA; arc=none smtp.client-ip=198.175.65.15 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=1708626458; x=1740162458; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=xM/QGOiRYmmtfXJfmB0d8tNDu2LXbkjtP1X6XvDL9RM=; b=OpFf+2VAFtINfUB28rfoiacXPE7CqLCfTHTpJHWStwC+yk8edRBCgdMN 7CagJQ86Xz7IGl5RWN+rXLc7Y2yEqs4TI4DsEos81513YSts4eJDYmJ4G 5+G7y33H8bVXrizQiixVVpkMgyh6+MBV2QdeCuS6n9dSkeHrUMJxICJZW 7NgfLwUnUZCgfDw26bdzF1T7pGFTGClgM9dfOky+FMcnCl2V2nrwGjFvk +3aOiJYe5w5GCPiZr+oi7PuVSAk5MWgF9iEH5+Sj2EzMZcxDsLmUxFus1 I6WLRSJBEAVPYkRy7QrRES7zJchM1eiq6xcDrQpO7ckaI0RmXkk3PYwn+ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10992"; a="6697326" X-IronPort-AV: E=Sophos;i="6.06,179,1705392000"; d="scan'208";a="6697326" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2024 10:27:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,179,1705392000"; d="scan'208";a="5552216" Received: from djiang5-mobl3.amr.corp.intel.com (HELO [10.246.114.198]) ([10.246.114.198]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2024 10:27:36 -0800 Message-ID: Date: Thu, 22 Feb 2024 11:27:35 -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 3/3 v5] cxl/memdev: Use cond_guard() in cxl_inject_poison() 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: <20240217105904.1912368-1-fabio.maria.de.francesco@linux.intel.com> <20240217105904.1912368-4-fabio.maria.de.francesco@linux.intel.com> From: Dave Jiang In-Reply-To: <20240217105904.1912368-4-fabio.maria.de.francesco@linux.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2/17/24 3:59 AM, Fabio M. De Francesco wrote: > Use cond_guard() in cxl_inject_poison() to not open code two up_write() > in an 'out' block. If the down_read_interruptible() fail, the statements > passed as the second argument of cond_guard() return -EINTR. > > Cc: Dave Jiang > Cc: Jonathan Cameron > Cc: Peter Zijlstra > Suggested-by: Dan Williams > Suggested-by: Ira Weiny > Signed-off-by: Fabio M. De Francesco Reviewed-by: Dave Jiang > --- > drivers/cxl/core/memdev.c | 19 +++++-------------- > 1 file changed, 5 insertions(+), 14 deletions(-) > > diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c > index dae8802ecdb0..bd97eea65bb0 100644 > --- a/drivers/cxl/core/memdev.c > +++ b/drivers/cxl/core/memdev.c > @@ -331,19 +331,13 @@ int cxl_inject_poison(struct cxl_memdev *cxlmd, u64 dpa) > if (!IS_ENABLED(CONFIG_DEBUG_FS)) > return 0; > > - rc = down_read_interruptible(&cxl_region_rwsem); > - if (rc) > - return rc; > + cond_guard(rwsem_read_intr, return -EINTR, &cxl_region_rwsem); > > - rc = down_read_interruptible(&cxl_dpa_rwsem); > - if (rc) { > - up_read(&cxl_region_rwsem); > - return rc; > - } > + cond_guard(rwsem_read_intr, return -EINTR, &cxl_dpa_rwsem); > > rc = cxl_validate_poison_dpa(cxlmd, dpa); > if (rc) > - goto out; > + return rc; > > inject.address = cpu_to_le64(dpa); > mbox_cmd = (struct cxl_mbox_cmd) { > @@ -353,7 +347,7 @@ int cxl_inject_poison(struct cxl_memdev *cxlmd, u64 dpa) > }; > rc = cxl_internal_send_cmd(mds, &mbox_cmd); > if (rc) > - goto out; > + return rc; > > cxlr = cxl_dpa_to_region(cxlmd, dpa); > if (cxlr) > @@ -366,11 +360,8 @@ int cxl_inject_poison(struct cxl_memdev *cxlmd, u64 dpa) > .length = cpu_to_le32(1), > }; > trace_cxl_poison(cxlmd, cxlr, &record, 0, 0, CXL_POISON_TRACE_INJECT); > -out: > - up_read(&cxl_dpa_rwsem); > - up_read(&cxl_region_rwsem); > > - return rc; > + return 0; > } > EXPORT_SYMBOL_NS_GPL(cxl_inject_poison, CXL); >