Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6792546rdb; Fri, 15 Dec 2023 08:25:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IGvxN/GEzSzlcFUylZmry+onvAv8urjfWAdViDE3YZskvJIU52eTfDF9dWY62pEStbIrk7U X-Received: by 2002:a05:6a20:3d89:b0:190:7b07:b7e4 with SMTP id s9-20020a056a203d8900b001907b07b7e4mr14252904pzi.10.1702657528251; Fri, 15 Dec 2023 08:25:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702657528; cv=none; d=google.com; s=arc-20160816; b=kKJLP7TzOvuXwWh6sacGDRT8g36CV6oPMSyZfuXANihh+3BVkeGgL1RaIyPsWZyfYb SiQ1xjGjH5efbRURdaPpEXaMwYGXn9+/85+UaYWfg7qmdBTTtvqsC0tCr4ejCJcHPj6/ x0/uuvQkKot2iNPbf9Jc5pOK3N94IJaaWg4r9jdugPGvQJRk7hfzp1koSLJ9gaD2Odea yZzFtLM+bgFw5xoi7Axye8H1fRpR750P1LUt1TCoGRYe4SeE95hNFLlL1ISUI+YrIHhU Z22lQb5c84/G8eALPIU5W5ZocJqapI4+k9SptX9xUslVvMjJmcFnGEJASDwjojeVrzRM qD9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5xwZ1/BBY0thJvVTjzjz4cgoup5PMl720ShIyPLU1dQ=; fh=U8QzjJJAhx6MTOmYysRrYNl3sh2FUsNWIjY0quPgtH0=; b=0UVxhfggSfUh5HJOUsfRPJVu7LD5wrB2VAu3Q6j5JlbNjv2dVzp6MJYTcfu3cqDriK K36IHFtKCEda/kg50wwMVGHQmDSNeW3ZGwF0WifyUZ8PrjwvDN19coelzA/qrQdYhlmA jlBSZQK93Q86oiKTqfgOxxXBMqLJFIbcDzm0rFaB/tghqu53c70Pd3qfeIaPz0/YoWX4 VP1l010dw5l23YuhWyDsPgSG14pgBsulh9Ssx/q1uAPgqNv8qDZ/P9VP80xcC5IADy1a yT1TO2pGte/NOXoegJyyahAYL9Jqxrv/T9OfQIWRmU4QGAJ0edv+MlLqmSCKBIMHW5MJ h11Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=b6hkFAZG; spf=pass (google.com: domain of linux-kernel+bounces-1274-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1274-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id fa16-20020a056a002d1000b006cddd78a8f1si13280015pfb.27.2023.12.15.08.25.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 08:25:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1274-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=b6hkFAZG; spf=pass (google.com: domain of linux-kernel+bounces-1274-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1274-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id E4940289ACE for ; Fri, 15 Dec 2023 16:14:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 70E8F3BB31; Fri, 15 Dec 2023 16:14:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="b6hkFAZG" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9BAB03DB8B; Fri, 15 Dec 2023 16:14:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA078C433C7; Fri, 15 Dec 2023 16:14:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1702656849; bh=4OqhZTmDHDfa6MzpLM8KMW5Z+d4w8EohcY6n1qhIOCQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=b6hkFAZGaxNHfOw7q/tXLyy1StzEIP29myEihwXcqVc/KANRpoWP8p1GdYjeEPpP4 cJ8iBxnm7LnDnHvIFzkoQP/vLYDyIwVPWDn72FvXm1UhQWvteoyZMpEj4HpnlZPtC5 oy0GgtILCeg+jFvmpKotyjONye8+HLPSzUrtd4nE= Date: Fri, 15 Dec 2023 17:14:07 +0100 From: "gregkh@linuxfoundation.org" To: "Verma, Vishal L" Cc: "willy@infradead.org" , "david@redhat.com" , "joao.m.martins@oracle.com" , "Jiang, Dave" , "akpm@linux-foundation.org" , "osalvador@suse.de" , "linux-cxl@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Williams, Dan J" , "dave.hansen@linux.intel.com" , "Huang, Ying" , "nvdimm@lists.linux.dev" , "linux-mm@kvack.org" Subject: Re: [PATCH v6 2/4] dax/bus: Use guard(device) in sysfs attribute helpers Message-ID: <2023121547-goldfish-snowplow-345f@gregkh> References: <20231214-vv-dax_abi-v6-0-ad900d698438@intel.com> <20231214-vv-dax_abi-v6-2-ad900d698438@intel.com> 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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Fri, Dec 15, 2023 at 06:33:58AM +0000, Verma, Vishal L wrote: > On Fri, 2023-12-15 at 05:56 +0000, Matthew Wilcox wrote: > > On Thu, Dec 14, 2023 at 10:25:27PM -0700, Vishal Verma wrote: > > > @@ -294,13 +294,10 @@ static ssize_t available_size_show(struct device *dev, > > > ????????????????struct device_attribute *attr, char *buf) > > > ?{ > > > ????????struct dax_region *dax_region = dev_get_drvdata(dev); > > > -???????unsigned long long size; > > > ? > > > -???????device_lock(dev); > > > -???????size = dax_region_avail_size(dax_region); > > > -???????device_unlock(dev); > > > +???????guard(device)(dev); > > > ? > > > -???????return sprintf(buf, "%llu\n", size); > > > +???????return sprintf(buf, "%llu\n", dax_region_avail_size(dax_region)); > > > ?} > > > > Is this an appropriate use of guard()?? sprintf is not the fastest of > > functions, so we will end up holding the device_lock for longer than > > we used to. > > Hi Matthew, > > Agreed that we end up holding the lock for a bit longer in many of > these. I'm inclined to say this is okay, since these are all user > configuration paths through sysfs, not affecting any sort of runtime > performance. Why does the lock have to be taken at all? You have a valid reference, isn't that all you need? thanks, greg k-h