Received: by 10.223.185.116 with SMTP id b49csp7704878wrg; Thu, 1 Mar 2018 09:40:39 -0800 (PST) X-Google-Smtp-Source: AG47ELvKv6PCO+i/0GthfpMz0aUgujRO+LYdYkfIcSfeK4K/sFbcM+WZOLro9B9PwiaFn4ISjKKT X-Received: by 10.99.133.193 with SMTP id u184mr2103387pgd.401.1519926038836; Thu, 01 Mar 2018 09:40:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519926038; cv=none; d=google.com; s=arc-20160816; b=h34Yy++lsAPeBD2qu44x+nXwOVOOSSXpHvpm4aamr1lA3NIGyavBtWb/1ObWt2DodM 7z+rEm6cDOiMo7dc6sCIJ+tu/B5lnJcv84umD8BscMS4bCTR9a4bjG1BzNDpXrlfS95O g7xm8bYXUikdykVVaiAu5aYbAlD2Um0DihNnOvu2kY38LPPoBtWLGrZHFWY3qTBB4eJN tjg6uDzCyyV+J3ONXj6KJ/tQeMfi24YRx8axHyLPvaUWO18BFe7GKVuXYLHjShWepZSO BP6D4PX5oK/IQpzfpc6BHV54UYfMBTLoNKgwArb0XkkKwmLYsTdzqWVKfS0SWxQFV6s9 i0mA== 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:arc-authentication-results; bh=YedhzVcy7iU/0wJ4IavmaYhuBJaTdXPC0RgRqaVL6jA=; b=lxmzxZPP7QeetdhoxagIOGpwUHcyQb4fYJ+7xmaRHmUpeD/A72QbxJAp/40+ddfWUs lSLWW06Td7zNDu8kCOP110YM+2Fb47dSjrgzeptHYOqVGeZTStPqSiJvJeFQ+9nzujRT ZPgfBjmMh3tU0xmJH5lfsXzikXIDX8nrISp8IdC2ZOY73Kn3EoYCI83wFxQwKITF0fIu 47rlOxjjGqJS+p5KuabsmN+MgOFMzbFFY0SX5ZdV+bYwCDusEPJ7Ewad7vXAyYL1ieyP EyDFxCNmYPUZXcfqDF8S4tuRZ40PeSpz/u7SmMA3BGpwkX/mPWq3TocDIS7tjwKOfy0/ X+Eg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u188si2698440pgc.785.2018.03.01.09.40.24; Thu, 01 Mar 2018 09:40:38 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033394AbeCARjm (ORCPT + 99 others); Thu, 1 Mar 2018 12:39:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33706 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033270AbeCARjl (ORCPT ); Thu, 1 Mar 2018 12:39:41 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3EEEC6DD80; Thu, 1 Mar 2018 17:39:41 +0000 (UTC) Received: from bfoster.bfoster (dhcp-41-20.bos.redhat.com [10.18.41.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C6CE608F2; Thu, 1 Mar 2018 17:39:41 +0000 (UTC) Received: by bfoster.bfoster (Postfix, from userid 1000) id 9178D120065; Thu, 1 Mar 2018 12:39:39 -0500 (EST) Date: Thu, 1 Mar 2018 12:39:39 -0500 From: Brian Foster To: Vratislav Bendel Cc: linux-xfs@vger.kernel.org, "Darrick J . Wong" , linux-kernel@vger.kernel.org Subject: Re: [PATCH] xfs: Correctly invert xfs_buftarg LRU isolation logic Message-ID: <20180301173939.GB34164@bfoster.bfoster> 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.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 01 Mar 2018 17:39:41 +0000 (UTC) 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. > Nit: unless > 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 > --- It might be worth pointing out in the commit log that currently isolated buffers end up right back on the LRU once they are released, because ->b_lru_ref remains elevated. Therefore, this patch essentially fixes that circuitous route by leaving them on the LRU as originally intended. Otherwise this looks Ok to me: Reviewed-by: Brian Foster Thanks for sending the patch. Brian > 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 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-xfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html