Received: by 10.223.185.116 with SMTP id b49csp7982564wrg; Thu, 1 Mar 2018 14:50:15 -0800 (PST) X-Google-Smtp-Source: AG47ELt1Vzk4kkTmI5rQ8uT2xGhaLCoC+wJKZC0Q0XqXhkxhF1ssFmAMt7bg7d7WXolpq/wrdZRf X-Received: by 10.98.88.5 with SMTP id m5mr3526713pfb.231.1519944614969; Thu, 01 Mar 2018 14:50:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519944614; cv=none; d=google.com; s=arc-20160816; b=fW0xsOw6NER1dMW60Mr387JV3fYdNFCkWOWyABn/cckv7YJlqeCxllMVN/YH4V54H8 4qYL8psSMWT6Mds7amFyH2Poz6KJRGtMU45LAVKzdMDb+otSkK8rHXLXy4Mdx+GRmpGV tBJY7bu7QDqp59gR9+5B+GNrOVhP8+a71zNHyJwOv5uMlBNjerJqi/OOCT62tQLOacu0 skrOERjJ1UODD5ibWYHX/dZbbpYcguQJkIELsdFuVlyF/J7iwWzDTssi01/RkNp91f8R nHcO/gUtnlXKmigrC3hdhG9dG6EHkD3D17bQlQF/3oVIp3Eirqr2kcEHs+TiZMPylXFa z36A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=IeeXZTwN669sdgwCMArAY6KACiXUApSRYKb0UCOk6hg=; b=U3YT2YSGhRg3isMrtB/EsrlGeKU+K+AQITIASZ0snhFeFNIu5GjponZCUC2gLFrfW3 ucl2i7AcV9eoSO/LXrVu+kMHT3AmYtv7cDct/gMNquxyCRd4FxXidcpZc1GGmfbdcUHd 8l2Q9NQoxoab3widBCmEFzYhHA47l8jvdseHPgOZHx6QRgB4ejHPE0G2RsW5Cv2AR5Fs xjfaXmQYKfT01MdN5oE1eRruCOk6FrCYQqIrUAehvgu6YBaf62Sc1eCQtTeoQG5ki6hP ZBvQ3c4snUNY+EWNTp+5PT9kU0Sv0S5hcdMagGoJVxBtllcv/9RAKHbw4fnd1RTM6cYR kOig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=KnBxT2g+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3si2989800pgc.496.2018.03.01.14.49.59; Thu, 01 Mar 2018 14:50:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=KnBxT2g+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162784AbeCAWsI (ORCPT + 99 others); Thu, 1 Mar 2018 17:48:08 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:53510 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162589AbeCAWsG (ORCPT ); Thu, 1 Mar 2018 17:48:06 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w21MlLam037661; Thu, 1 Mar 2018 22:48:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2017-10-26; bh=IeeXZTwN669sdgwCMArAY6KACiXUApSRYKb0UCOk6hg=; b=KnBxT2g+E1akaKU1/dQyQRTZru9sAEZ9RW5hIbK46k8vU7ZS24gLDkxc0lIRWDl30cp1 j8HeSbQURfw0CDcq/y+WkDcLLpj511Y+xpZhM8Hj96Lo8t98l2MEiMOSMHqfnbGYhr4R zgl2qn+dlmMa6ZbEZ6GPNwiskLq8/6751izibGjhVWfPYOUR3CbuuSNvS50dDMKJRD/+ bzqNLW9C9Q/VheKMsvoTFTbYil8c1V5VTwX0Zn+WpqNxi0FhKvrjJwAsmFxZvlyUzinV 2pt+oLSxOeQqokJICErFZVKo6DusHlHUUqENmyELY3R4pWRRo7Us/GlQVPjwW10/DKuS uQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2gesqa06f9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Mar 2018 22:48:02 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w21Mm2Cs000559 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 1 Mar 2018 22:48:02 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w21Mm10l025845; Thu, 1 Mar 2018 22:48:01 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 01 Mar 2018 14:48:01 -0800 Date: Thu, 1 Mar 2018 14:48:00 -0800 From: "Darrick J. Wong" To: Vratislav Bendel Cc: linux-xfs@vger.kernel.org, Brian Foster , linux-kernel@vger.kernel.org, djwong@kernel.org Subject: Re: [PATCH] xfs: Correctly invert xfs_buftarg LRU isolation logic Message-ID: <20180301224800.GI12763@magnolia> References: <20180228154951.31714-1-vbendel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180228154951.31714-1-vbendel@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8819 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803010276 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 28, 2018 at 04:49:51PM +0100, Vratislav Bendel wrote: > The function xfs_buftarg_isolate() used by xfs buffer schrinkers > to determine whether a buffer should be isolated and disposed > from LRU list, has inverted logic. > > Excerpt from xfs_buftarg_isolate(): > /* > * Decrement the b_lru_ref count unless the value is already > * zero. If the value is already zero, we need to reclaim the > * buffer, otherwise it gets another trip through the LRU. > */ > if (!atomic_add_unless(&bp->b_lru_ref, -1, 0)) { > spin_unlock(&bp->b_lock); > return LRU_ROTATE; > } > > However, as per documentation, atomic_add_unless() returns _zero_ > if the atomic value was originally equal to the specified *unsless* value. > > Ultimately causing a xfs_buffer with ->b_lru_ref == 0, to take another > trip around LRU, while isolating buffers with non-zero b_lru_ref. > > Signed-off-by: Vratislav Bendel > CC: Brian Foster Looks ok, will test... Reviewed-by: Darrick J. Wong --D > --- > fs/xfs/xfs_buf.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c > index d1da2ee9e6db..ac669a10c62f 100644 > --- a/fs/xfs/xfs_buf.c > +++ b/fs/xfs/xfs_buf.c > @@ -1708,7 +1708,7 @@ xfs_buftarg_isolate( > * zero. If the value is already zero, we need to reclaim the > * buffer, otherwise it gets another trip through the LRU. > */ > - if (!atomic_add_unless(&bp->b_lru_ref, -1, 0)) { > + if (atomic_add_unless(&bp->b_lru_ref, -1, 0)) { > spin_unlock(&bp->b_lock); > return LRU_ROTATE; > } > -- > 2.14.3 >