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 E0FB1C3DA6E for ; Wed, 10 Jan 2024 08:46:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 51EC26B0080; Wed, 10 Jan 2024 03:46:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4D14D6B0081; Wed, 10 Jan 2024 03:46:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3968B6B0083; Wed, 10 Jan 2024 03:46:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 290E86B0080 for ; Wed, 10 Jan 2024 03:46:44 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id EB799C0469 for ; Wed, 10 Jan 2024 08:46:43 +0000 (UTC) X-FDA: 81662770686.16.49C42DB Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf27.hostedemail.com (Postfix) with ESMTP id AE2884001A for ; Wed, 10 Jan 2024 08:46:41 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=rbRHB8TW; dkim=pass header.d=suse.com header.s=susede1 header.b=rbRHB8TW; spf=pass (imf27.hostedemail.com: domain of mhocko@suse.com designates 195.135.223.130 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704876402; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=dAMBtYxlnvekwyaz5hr/7HwB3du2CWI3iMgQMYoSubo=; b=ctSn8oMbLyRzRfRXMQNEFX7GrZDNEpemOt6T35nFWo4NC4/6+aFc8SgAfZ3E6Ed9TBQeiK 8mtUZ0gAYX8CBjtNWtxCvRXtYAjpyOETmBt877d+/8vem2Jo0h/J7qAlPkfyPDskiLVNml K44f0uVlgM4FXdvhk25gxvhYfKAPZRQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704876402; a=rsa-sha256; cv=none; b=UrFn8XGb/I86Ikgbs1Kbm2sITu9zmNIKFOWB5M2uzOihX0ChMvVhY6LBfkSHLeyO8/bK8h ohGWTr43XuKVFwlQKqb5enFdRKrSceDG2IiR69zx0ZdZMDcUyJcKZwHpgSjRk2ddQ0o5br 29UxEDZERddtLqfk6gLqrBOE7YfuqKM= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=rbRHB8TW; dkim=pass header.d=suse.com header.s=susede1 header.b=rbRHB8TW; spf=pass (imf27.hostedemail.com: domain of mhocko@suse.com designates 195.135.223.130 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id B6AB421C56; Wed, 10 Jan 2024 08:46:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1704876399; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=dAMBtYxlnvekwyaz5hr/7HwB3du2CWI3iMgQMYoSubo=; b=rbRHB8TWWTkXJMRrgKyAZpxrf8arJY85UXcKVMHZKx7eChVd0m6TdKbHFIB4qQO1h3LB2N MVnWx7DLNNSy+BzPPoYdylwOCQbJ5wU5eHe7wvjCQNdwAbGaNGbdCfcJ1ypMKkc2Z3oRuQ xF6hZWpzS62/V9mI32lqHnr6cqn+XyI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1704876399; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=dAMBtYxlnvekwyaz5hr/7HwB3du2CWI3iMgQMYoSubo=; b=rbRHB8TWWTkXJMRrgKyAZpxrf8arJY85UXcKVMHZKx7eChVd0m6TdKbHFIB4qQO1h3LB2N MVnWx7DLNNSy+BzPPoYdylwOCQbJ5wU5eHe7wvjCQNdwAbGaNGbdCfcJ1ypMKkc2Z3oRuQ xF6hZWpzS62/V9mI32lqHnr6cqn+XyI= Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 930B613786; Wed, 10 Jan 2024 08:46:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id aIINIm9ZnmUDcQAAD6G6ig (envelope-from ); Wed, 10 Jan 2024 08:46:39 +0000 Date: Wed, 10 Jan 2024 09:46:39 +0100 From: Michal Hocko To: Jianfeng Wang Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm, oom: Add lru_add_drain() in __oom_reap_task_mm() Message-ID: References: <20240109091511.8299-1-jianfeng.w.wang@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240109091511.8299-1-jianfeng.w.wang@oracle.com> X-Spamd-Bar: ++ X-Rspamd-Queue-Id: AE2884001A X-Rspam-User: X-Stat-Signature: 7d9apzjrorrdytu5dz7epoexw9f1uhs3 X-Rspamd-Server: rspam03 X-HE-Tag: 1704876401-2470 X-HE-Meta: U2FsdGVkX1/mygBpVk6nPE2k7zjJuYBzGyLn7txDuUI4yrMxi80sJiRNeyXgERB5Xexrr7t9hbhqOVC5EyV728LcqN4nMnf3ltaPYbxA9eS7VUtJZJ84bd0AUoSG2neVC2CMzB1SuBBzQ6lf5SpPv0x2oNcZiUXKXWQk5ELLHHshfcyUjkBMz3g1Ac6+GVTLobMgj3qz9yaYjut+UlkYwtuA35+KefR/A/iH9Fo/06Q4ZXLWYXwbvBtNF8lhS6J+N+yYWGtEaEiJqj4FHOhMcWh+lRBMVeL13shisfQb7ldF/NaMI8Tn+7IKW7jcmYoXHcOC7KFAO0Aw0trDKmDf2i8eiDT9LWPx75tvFWAjD3FW01aYA/KmzGcSvrP61wEmqqqLx7m/QRWfah3Df4eBS4QunBv4W3EWUrehrjaBjWvp23Rl93jvRs9D9qWvY06am9Nb+54Aa5FiZ5a8NZOe0KKdrSyKqgPi21lY2cwIxMymJRyOM0NE6BIQWdRtydwtsbf0PYUeICe3TVTz0Qv32MicxPauRBFbQFVoPmxCn/dKMBDBxkTWzO9gtCbDprsWq+GRxys0sXjpc/1JT/yn+ZSiZCWCMXtN3UPyQbI4X2WfSI4ADJL7ZTB2ZtTRUy/sjF/Pj8kS57T6kOWvHaZL8mwbR/6r0JOOdFiMdkszfNJKr1SYJB+i4cJhf/Z0DCOPWeaBAfuciUkSfUFUnhczi5IV3lIvhyl7bsnbu5Ax5g7xZYysVA3U+IRNuDGBmAa9aG0+nRWN4pKs93ejZ25/kPSSznQBeBIyjDX6C6LRMqIY15xJE8etor1DeVN+fXwozmywdnOII7z3rrstrLtti/Tbt49JTlyIwx3Zvm1ypGo3hbyEBLEBn7t6FMp+HdTjN4SxACCVMTo2jehog+MCvhWH2ZuBkEhG/lNlngvjBx4Q2mhWa7xyLJa2Cfyz3T+HSAJMwtSv5z/CTNB7+E5 0Ni8f5Hj AK5jKxdgPq+i/EUqHHrbdAEv9cuahzRYB5NU7mSuY/w/s4bleRySRfTvKqGUnCI2AdnsqgaN907IQ+2wYSupZkg80i1u1kTQryiwzJQ9nvRbjy/KKkLRlLOEQaRpx8lvCod9mWvCye2kF4Nne/DglJhOLvaEQN9o315fxhsRb35WAcZGBcqd2dB7yuJp0qiGwRTVrXOJTyFkdpzJwCkoXI5JBf8a35yfVXYuGmMSMKLRI3ewYnQF0SQ7C/EOucq9yq9CyLu2gLYOIBtIJTkG8rU5+9/LxPUbXb4Mi X-Bogosity: Ham, tests=bogofilter, spamicity=0.000004, 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 Tue 09-01-24 01:15:11, Jianfeng Wang wrote: > The oom_reaper tries to reclaim additional memory owned by the oom > victim. In __oom_reap_task_mm(), it uses mmu_gather for batched page > free. After oom_reaper was added, mmu_gather feature introduced > CONFIG_MMU_GATHER_NO_GATHER (in 'commit 952a31c9e6fa ("asm-generic/tlb: > Introduce CONFIG_HAVE_MMU_GATHER_NO_GATHER=y")', an option to skip batched > page free. If set, tlb_batch_pages_flush(), which is responsible for > calling lru_add_drain(), is skipped during tlb_finish_mmu(). Without it, > pages could still be held by per-cpu fbatches rather than be freed. > > This fix adds lru_add_drain() prior to mmu_gather. This makes the code > consistent with other cases where mmu_gather is used for freeing pages. Does this fix any actual problem or is this pure code consistency thing? I am asking because it doesn't make much sense to me TBH, LRU cache draining is usually important when we want to ensure that cached pages are put to LRU to be dealt with because otherwise the MM code wouldn't be able to deal with them. OOM reaper doesn't necessarily run on the same CPU as the oom victim so draining on a local CPU doesn't necessarily do anything for the victim's pages. While this patch is not harmful I really do not see much point in adding the local draining here. Could you clarify please? > Signed-off-by: Jianfeng Wang > --- > mm/oom_kill.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/mm/oom_kill.c b/mm/oom_kill.c > index 9e6071fde34a..e2fcf4f062ea 100644 > --- a/mm/oom_kill.c > +++ b/mm/oom_kill.c > @@ -537,6 +537,7 @@ static bool __oom_reap_task_mm(struct mm_struct *mm) > struct mmu_notifier_range range; > struct mmu_gather tlb; > > + lru_add_drain(); > mmu_notifier_range_init(&range, MMU_NOTIFY_UNMAP, 0, > mm, vma->vm_start, > vma->vm_end); > -- > 2.42.1 > -- Michal Hocko SUSE Labs