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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 82A5AE77188 for ; Thu, 16 Jan 2025 07:51:27 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4YYZn95F2Wz3cdM for ; Thu, 16 Jan 2025 18:51:25 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=115.124.30.132 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1737013883; cv=none; b=LuLo51qw54D9EC3SykVFxRA9Ly/t/8cEzk+rKh+zRxgurn0zCVUsXgDvGygJQ4JP6fmuraOM/o9vlBDw5QiO9l01rqXXC2d+tVb+f0bLvwryhco2ngISMhDEHWJa+OdXulaDIY6im0HtrUuv0TSuBGpsE6PS4a0EdV99cUu5KMjm4dS7Y9DmKTwCCI/Im3DzMFXqV5yhNHCWxFnZcdXPDDWD5iZtE2ajhlv2EzmyhXQXql36dJZ2z9r1RVnj1JzCVCjCXErDuT2fd0A2y8FWEMF+0dJpmeZynyN282pau9MWqtr9xphxUGOARHlJTc35arBV7Wy2eyCk54xFQEZ8Bw== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1737013883; c=relaxed/relaxed; bh=5/uQUXKHYLMtTWj1lVfWlv4rTg4eAI8aIXpMUNNc0hU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Wu30pih8rYQ/ejGZukmBrtkCaDmUmR/+sgJSvT34yY2tlxir3zaNoZ5ota9QfE9M9ua9rXREc+Z1VMBi7G4U1Kf1GS5l7XNAh8w65Z3Nhex6/UJ4UYPyPG1DKA68jALWJ/18eMZSAWaVD1DK9LfgkzYivZxJ9+5Abb+Y0uhllNu+dMyqWHPxg1AWdAGpW7ZZ6hI0VIjyJenkO2/pUVfVrAgfswB59kNkDCYpAAn1kcZ1f5WdpfHwcma4EdYRbVlGs6s0TubkBBXofI/YzA/jQSnR17P7eDuYc7FUwHAUl/PknN9VOluTi/aLTGiQrcke0nMAII62Q3lFyOSnybM93Q== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; dkim=pass (1024-bit key; unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=XcOSR6uB; dkim-atps=neutral; spf=pass (client-ip=115.124.30.132; helo=out30-132.freemail.mail.aliyun.com; envelope-from=hsiangkao@linux.alibaba.com; receiver=lists.ozlabs.org) smtp.mailfrom=linux.alibaba.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=XcOSR6uB; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.alibaba.com (client-ip=115.124.30.132; helo=out30-132.freemail.mail.aliyun.com; envelope-from=hsiangkao@linux.alibaba.com; receiver=lists.ozlabs.org) Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4YYZn527Hcz2ysg for ; Thu, 16 Jan 2025 18:51:19 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1737013875; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=5/uQUXKHYLMtTWj1lVfWlv4rTg4eAI8aIXpMUNNc0hU=; b=XcOSR6uBurdPmHyxo72quHRmdj93D8PgG6jkZrDTZg5K/82qRfx4Rj7xfmowA28VASCllBYG9mOzT75VhfSPKJ+q0V1vAmlKLbKxo5Da2kOy2XNBWCFaC4FroFuG7ho39M2jgoUmzuuejwOd+0pZJKhj+b1ZKP29PAI6se6Pp6E= Received: from 30.221.130.221(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0WNksvNR_1737013872 cluster:ay36) by smtp.aliyun-inc.com; Thu, 16 Jan 2025 15:51:13 +0800 Message-ID: Date: Thu, 16 Jan 2025 15:51:12 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] erofs(shrinker): return SHRINK_EMPTY if no objects to free To: Chen Linxuan , Gao Xiang , Chao Yu , Yue Hu , Jeffle Xu , Sandeep Dhavale References: <433DB98624BCDF95+20250116072042.189710-1-chenlinxuan@uniontech.com> From: Gao Xiang In-Reply-To: <433DB98624BCDF95+20250116072042.189710-1-chenlinxuan@uniontech.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: linux-erofs@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development of Linux EROFS file system List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org Errors-To: linux-erofs-bounces+linux-erofs=archiver.kernel.org@lists.ozlabs.org Sender: "Linux-erofs" Hi Linxuan, On 2025/1/16 15:20, Chen Linxuan wrote: > Comments in file include/linux/shrinker.h says that > `count_objects` of `struct shrinker` should return SHRINK_EMPTY > when there are no objects to free. > >> If there are no objects to free, it should return SHRINK_EMPTY, >> while 0 is returned in cases of the number of freeable items cannot >> be determined or shrinker should skip this cache for this time >> (e.g., their number is below shrinkable limit). Thanks for the patch! Yeah, it seems that is the case. Yet it'd better to document what the impact if 0 is returned here if you know more.. > > Signed-off-by: Chen Linxuan > --- > fs/erofs/zutil.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/fs/erofs/zutil.c b/fs/erofs/zutil.c > index 0dd65cefce33..682863fa9e1c 100644 > --- a/fs/erofs/zutil.c > +++ b/fs/erofs/zutil.c > @@ -243,7 +243,9 @@ void erofs_shrinker_unregister(struct super_block *sb) > static unsigned long erofs_shrink_count(struct shrinker *shrink, > struct shrink_control *sc) > { > - return atomic_long_read(&erofs_global_shrink_cnt); > + unsigned long count = atomic_long_read(&erofs_global_shrink_cnt); > + > + return count ? count : SHRINK_EMPTY; I guess you could just use return atomic_long_read(&erofs_global_shrink_cnt) ?: SHRINK_EMPTY; Thanks, Gao Xiang > } > > static unsigned long erofs_shrink_scan(struct shrinker *shrink,