Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp843379rdd; Wed, 10 Jan 2024 00:47:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IEi65AkaDY24P6wt2xXCEp1DxxHe+gldpKjqlSDsLGpvVYoGRCYXU2SgWm5RW3bxKaa5AfK X-Received: by 2002:a05:620a:4d11:b0:781:31cd:41bf with SMTP id wa17-20020a05620a4d1100b0078131cd41bfmr733036qkn.120.1704876426568; Wed, 10 Jan 2024 00:47:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704876426; cv=none; d=google.com; s=arc-20160816; b=RSKl4av4JgnUekEtJghdu8+mUqLaB3T6PwNETwDnyFWxe7xZkEGKHVasP8sBHDBsF3 /bBGtxHQxHlwci31YqvalsSlTgyPkObgrM2EzatoFxutf092EEAXbAurfA9gGuH0BJAj 828BpUGyNfStwq6dZEFlBNMCMPTU+677Alairly7972p0hHaVf+X5Eq/4ePfBqpdcl5X MWELJpGi/klq8UCKvKMZRmmq7kHtYb0NBuCuKPlwzg6HlpgOYbda1WY3rBipiVrNWY3q dlnEp/zdgQh07YCv7/+oZT2jmHRJO8fMctCfIisFmOrbYXQT115i2Uo8j57IqVmHNONp Yg7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature; bh=dAMBtYxlnvekwyaz5hr/7HwB3du2CWI3iMgQMYoSubo=; fh=F1oKRlR1MEmbXOQYUFziTg3SjwNEUeuoiz+rro56J48=; b=XpwgZqVKHbfuqUxgqMGlVnKCMSxg1FnwaXo9PpuEG3gpbfmkXWNxY1T+vSAVhU8YuA wviGEriKhDBsZJ/xBtTW+fadMlG9Mim+8bD0ZHvu1gFMtkG+H/w2fPn2AqfLCWd4lioA jBER4eDJAJt324ANYgsMTqBnvXTLTiaLs4qNsPR18addKKZbKn4+2h3UCYrLJDGM/Q9b wPDWrSQCOW5lDi6/3NhHDHlZeFk8Fr8C9Hu3RlzLj6AE+5RzDU63VQ77FZ07m+MTYQVE 5zoWHxYVPyvHrVJS/NE0fePaFqr8NFJWSaP1BleqlHALfyGOyO6mun0+4qmMkX72TGQF dyGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=rbRHB8TW; dkim=pass header.i=@suse.com header.s=susede1 header.b=rbRHB8TW; spf=pass (google.com: domain of linux-kernel+bounces-21860-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21860-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id bj5-20020a05620a190500b0078331661d3dsi2297986qkb.594.2024.01.10.00.47.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 00:47:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-21860-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=rbRHB8TW; dkim=pass header.i=@suse.com header.s=susede1 header.b=rbRHB8TW; spf=pass (google.com: domain of linux-kernel+bounces-21860-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21860-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 5615C1C24686 for ; Wed, 10 Jan 2024 08:47:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AC4E03B199; Wed, 10 Jan 2024 08:46:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="rbRHB8TW"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="rbRHB8TW" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23CCB3B190 for ; Wed, 10 Jan 2024 08:46:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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-Spam-Level: ** X-Spamd-Bar: ++ Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=rbRHB8TW X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [2.29 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; DKIM_TRACE(0.00)[suse.com:+]; MX_GOOD(-0.01)[]; NEURAL_SPAM_LONG(3.50)[1.000]; DBL_BLOCKED_OPENRESOLVER(0.00)[oracle.com:email,suse.com:dkim]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; MID_RHS_NOT_FQDN(0.50)[]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-1.20)[89.15%] X-Spam-Score: 2.29 X-Rspamd-Queue-Id: B6AB421C56 X-Spam-Flag: NO 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