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.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (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 3A581C0015E for ; Fri, 28 Jul 2023 08:19:26 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1qPIh2-0005Uo-0H; Fri, 28 Jul 2023 08:19:25 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1qPIh0-0005Ub-Bd for linux-f2fs-devel@lists.sourceforge.net; Fri, 28 Jul 2023 08:19:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: From:References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=0Vz5i3f1KwBqEHtOj3kkD+u+idA4hMEDLOXYQ/Zmb7I=; b=AWgSVBBb2EfmPltPz3Dq00jIjt GNwaG10VqRSNBu5rSci6lEy6eYt3Wds8T2GVHkEK4L8cSaPAuxA/B+bvb1ocnk6vWGyRoOf7tHbD8 Uw529Jzwsz9fbqD59DO/oA0oyZaMdtKf1ik1s4/r9wZ/3FhlK2ARmt9gTGD02GDz6BlM=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=0Vz5i3f1KwBqEHtOj3kkD+u+idA4hMEDLOXYQ/Zmb7I=; b=bwQ5uGWPZ2KwLQCoHlbY9SBl0C mLFImLkUSbJIpZYkfKuItDB/3eehBY4pWqT+xLFbbOqAODz2xsQ1lQexkeYVbbnsJrKjDqOmtFCuu ngjzeuEJsmngxJZJc5w/II8bezbbVFRO1guXRJTKa2d1J/LJIpC0UIlW3k4ikOMXKr+U=; Received: from mail-pf1-f176.google.com ([209.85.210.176]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1qPIgy-005KTq-QI for linux-f2fs-devel@lists.sourceforge.net; Fri, 28 Jul 2023 08:19:23 +0000 Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-6748a616e17so437602b3a.1 for ; Fri, 28 Jul 2023 01:19:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690532355; x=1691137155; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=0Vz5i3f1KwBqEHtOj3kkD+u+idA4hMEDLOXYQ/Zmb7I=; b=L2+elQ31DoTndDMbULUpYhAiCoRfDRGWwRsLhePlw7WW3kXFI6RoGNteAO7MNCCxPK FYWrT0NCxgniYdOvtk354oC7lAaEYLaI5+6nbBgCsJS7Z9F7PQNW+ZUGwlLgRq4XIWCd IlyzJlPUeNX37jF32KJvYLJePzYsZ7ze/fbSuG8EqYw256JXY3KCKzS1wluS9KcnHJgS wVJn5VLovDZDoJav6s/8z2Nev3fZMa4BKzS6r7L/dPmXUhh82k37p3M1JnHGLMc145hK MLBcl9i8u/Uj6MSDKzSJ+fdKEdHQ4PpsFlNhyTOhfKom9VA3y6JlxMc/+2lHqKKi6hTK U83g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690532355; x=1691137155; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=0Vz5i3f1KwBqEHtOj3kkD+u+idA4hMEDLOXYQ/Zmb7I=; b=dtNIotuJzWhpcNl2wq1tPDrOR+xlJ5Oib1TOHJSL7hBXKqf2ef016CyN8FsBpqWj6a tjLlNw7D2zwhjbp8neH+0+hUDHY6WExiGXwT/2HJDAyGZp78EyWxL1TZDfE6DH/KgcsM pCL6LoTNSi+fq1IdzQNWPvXHOvDRYfYz2Ouh1cNCrQwa7ZEflxoIHJYU8JM8c4GuDD6/ k8YUdMFylrgNgFkVXKlzhQrB4HxTLxv4Js6QzWBSR7tn3ToPpL+xtQWXT94lB0aGL858 wKBmf8xxUCdEieMUQa+AYjHeOYM2Xb0GQVVArsS7wYM3uSmkj9CduQKjUjJJ5ErU3uiK f91Q== X-Gm-Message-State: ABy/qLbOrbAhxoOR6AkzDWMERPSY9asmGUXpjbbJlv2zjkxGefATHLCF iJRPME4K6tKuK43DErYRSx4EQA== X-Google-Smtp-Source: APBJJlFUUUMvBrf6ibd1LKjgOpEN2XEkSNdXdEqaA3c50PeJDSflhjqiMTE27IMY1LDD8QpZTvY8yg== X-Received: by 2002:a05:6a21:329f:b0:134:76d6:7f7 with SMTP id yt31-20020a056a21329f00b0013476d607f7mr2068612pzb.4.1690532355159; Fri, 28 Jul 2023 01:19:15 -0700 (PDT) Received: from [10.70.252.135] ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id j63-20020a638b42000000b005637030d00csm2862658pge.30.2023.07.28.01.19.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Jul 2023 01:19:14 -0700 (PDT) Message-ID: <99d0958d-8446-6fe9-a0fb-f562cb04c7c8@bytedance.com> Date: Fri, 28 Jul 2023 16:19:01 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Content-Language: en-US To: Simon Horman References: <20230727080502.77895-1-zhengqi.arch@bytedance.com> <20230727080502.77895-5-zhengqi.arch@bytedance.com> In-Reply-To: X-Headers-End: 1qPIgy-005KTq-QI Subject: Re: [f2fs-dev] [PATCH v3 04/49] mm: shrinker: remove redundant shrinker_rwsem in debugfs operations X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Qi Zheng via Linux-f2fs-devel Reply-To: Qi Zheng Cc: kvm@vger.kernel.org, djwong@kernel.org, roman.gushchin@linux.dev, david@fromorbit.com, dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org, linux-mm@kvack.org, dm-devel@redhat.com, linux-mtd@lists.infradead.org, cel@kernel.org, x86@kernel.org, steven.price@arm.com, cluster-devel@redhat.com, xen-devel@lists.xenproject.org, linux-ext4@vger.kernel.org, paulmck@kernel.org, linux-arm-msm@vger.kernel.org, linux-nfs@vger.kernel.org, rcu@vger.kernel.org, linux-bcache@vger.kernel.org, Muchun Song , yujie.liu@intel.com, vbabka@suse.cz, linux-raid@vger.kernel.org, brauner@kernel.org, tytso@mit.edu, gregkh@linuxfoundation.org, muchun.song@linux.dev, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org, senozhatsky@chromium.org, netdev@vger.kernel.org, linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org, linux-erofs@lists.ozlabs.org, linux-btrfs@vger.kernel.org, tkhai@ya.ru Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Hi Simon, On 2023/7/28 16:13, Simon Horman wrote: > On Thu, Jul 27, 2023 at 04:04:17PM +0800, Qi Zheng wrote: >> The debugfs_remove_recursive() will wait for debugfs_file_put() to return, >> so the shrinker will not be freed when doing debugfs operations (such as >> shrinker_debugfs_count_show() and shrinker_debugfs_scan_write()), so there >> is no need to hold shrinker_rwsem during debugfs operations. >> >> Signed-off-by: Qi Zheng >> Reviewed-by: Muchun Song >> --- >> mm/shrinker_debug.c | 14 -------------- >> 1 file changed, 14 deletions(-) >> >> diff --git a/mm/shrinker_debug.c b/mm/shrinker_debug.c >> index 3ab53fad8876..f1becfd45853 100644 >> --- a/mm/shrinker_debug.c >> +++ b/mm/shrinker_debug.c >> @@ -55,11 +55,6 @@ static int shrinker_debugfs_count_show(struct seq_file *m, void *v) >> if (!count_per_node) >> return -ENOMEM; >> >> - ret = down_read_killable(&shrinker_rwsem); >> - if (ret) { >> - kfree(count_per_node); >> - return ret; >> - } >> rcu_read_lock(); > > Hi Qi Zheng, > > As can be seen in the next hunk, this function returns 'ret'. > However, with this change 'ret' is uninitialised unless > signal_pending() returns non-zero in the while loop below. Thanks for your feedback, the 'ret' should be initialized to 0, will fix it. Thanks, Qi > > This is flagged in a clan-16 W=1 build. > > mm/shrinker_debug.c:87:11: warning: variable 'ret' is used uninitialized whenever 'do' loop exits because its condition is false [-Wsometimes-uninitialized] > } while ((memcg = mem_cgroup_iter(NULL, memcg, NULL)) != NULL); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > mm/shrinker_debug.c:92:9: note: uninitialized use occurs here > return ret; > ^~~ > mm/shrinker_debug.c:87:11: note: remove the condition if it is always true > } while ((memcg = mem_cgroup_iter(NULL, memcg, NULL)) != NULL); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 1 > mm/shrinker_debug.c:77:7: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] > if (!memcg_aware) { > ^~~~~~~~~~~~ > mm/shrinker_debug.c:92:9: note: uninitialized use occurs here > return ret; > ^~~ > mm/shrinker_debug.c:77:3: note: remove the 'if' if its condition is always false > if (!memcg_aware) { > ^~~~~~~~~~~~~~~~~~~ > mm/shrinker_debug.c:52:9: note: initialize the variable 'ret' to silence this warning > int ret, nid; > ^ > = 0 > >> >> memcg_aware = shrinker->flags & SHRINKER_MEMCG_AWARE; >> @@ -92,7 +87,6 @@ static int shrinker_debugfs_count_show(struct seq_file *m, void *v) >> } while ((memcg = mem_cgroup_iter(NULL, memcg, NULL)) != NULL); >> >> rcu_read_unlock(); >> - up_read(&shrinker_rwsem); >> >> kfree(count_per_node); >> return ret; > > ... _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel