From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB85DC4332F for ; Fri, 15 Dec 2023 16:14:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D7A766B04EF; Fri, 15 Dec 2023 11:14:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D280B8D0121; Fri, 15 Dec 2023 11:14:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BF0506B04F3; Fri, 15 Dec 2023 11:14:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id B0A6D6B04EF for ; Fri, 15 Dec 2023 11:14:13 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 734C6160D7C for ; Fri, 15 Dec 2023 16:14:13 +0000 (UTC) X-FDA: 81569549586.14.E0CA97F Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf11.hostedemail.com (Postfix) with ESMTP id B29F34000A for ; Fri, 15 Dec 2023 16:14:11 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=b6hkFAZG; spf=pass (imf11.hostedemail.com: domain of gregkh@linuxfoundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org; dmarc=pass (policy=none) header.from=linuxfoundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702656851; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=5xwZ1/BBY0thJvVTjzjz4cgoup5PMl720ShIyPLU1dQ=; b=uYvN9si27DWTsw0h1Uh2n/3/J2dZCAl3Lm9DpJbfaNLelNGTiqrpKA6zihB8rOArRDOZY2 0+Nb7KkSABgLzZxXArFRtIrHuOk9HY3badzHWazkP5Nr5/DL5zwlM4R0uryucsoNze7rR8 whiYfON1ak8lmpamdWEBfaD7/D+7WLE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702656851; a=rsa-sha256; cv=none; b=cfLyE+EVQlJJLw+4KCZdHUo4EIpCqQmmtS01BZ46uHTYC8mkGxLKu9t9Ea2FfEdkFFTM9v U9sLwKzAxOy1CN1rCaDUrj0iKpxLFJXYasJuEXH5wy7rvQFrX8a19hIk6PIlM+pE9IFb2e +Xc3y0DUvwMbmIBHgnju61pZjuttBv0= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=b6hkFAZG; spf=pass (imf11.hostedemail.com: domain of gregkh@linuxfoundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org; dmarc=pass (policy=none) header.from=linuxfoundation.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id 18595B8297C; Fri, 15 Dec 2023 16:14:10 +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> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Queue-Id: B29F34000A X-Rspam-User: X-Stat-Signature: dn414uc84xsrjs6f9aam35fz9k43quuj X-Rspamd-Server: rspam03 X-HE-Tag: 1702656851-938214 X-HE-Meta: U2FsdGVkX1+ZrayUxb73PklaZjDU/evnLacwX29giT+KxW8Xf69mGp7iG+j4jR8Oez1902GhR306r48rHMrPyFM9fPYxZA4544bkrCvSahmI4Psc3i2BFdajNxRMPeHx65/l/yOuqZt+gF+jJQcNpGfUpXCEZFYykWaIeyqqC3TZQFb8Ph7TkD6UlruZPv9kMEtAppreig6R1s/K4jzdRwgKlhAmozSDLZV5HM2Q9nEvxgk/ZavOOUOXS+gzs1AfxmsXAYApbYKnrCVGpci27d9SjKdvQIhiFPizlWoRHLoztKnbWJuvhXmqbe+hZ17QzBKgTzpcoD3V38jnzZyqL7y76932NzI0EQm0e5spMljzU29jN0gtJuMTiXH1N0kn95W/Vab32NhKSc1jLlflriGjRJjMAGbElgXFgFf7UaYtspr1MsrhnNB5HcuZKx80tetjNK3wO2N/7+Bt+Agl4b3x7dWt7vd+TKNXJQBt3oCJSvld5iJTGdT+Ka6JpRNDZZfUTaNli9IIr9Fz8s074oIU3LGqvzHlHG0teWlO6EDnMJDAfk1Jwftn85wFSFeUAphu98ZsBB/X/FGP+9QK6lWof7rhLtHEctc+G5ybJcUkkpMGwj435CIw1jDENHLAMltXIQCiw7z050ojPW82EfAn5OJGAljj1D86j0Mi6IRlcvzSSgFo46k8ctcSizqrVzQzmV+RWcd47wJ1+CktucZ4vPxcFCIia0+t4oS06w/sAKiMzzD4uMPikstexwJ4hOLZRCN9glHYEZyADwmQGwqS7gC+uhhv5MW+kUHHmxEku22Sk2GYE8AXT9T5lKiyLIolkJOkgq/UinTEUbRDkW3RWZHxhYbn1a4vRYcNcnkz880x17DUE2PafE0Q7OqV5E6BE0ZGAuW06oZd1UkxIRWU+6On7cm/K+FKv5zicwY+JMN1QxRDMu4Rby9Y/6744qiLiIOU5dB+3z+wnhD 8Fg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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