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 D69FEECAAA2 for ; Sun, 28 Aug 2022 19:50:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DE84A940008; Sun, 28 Aug 2022 15:50:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D98AD940007; Sun, 28 Aug 2022 15:50:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C6027940008; Sun, 28 Aug 2022 15:50:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id B3863940007 for ; Sun, 28 Aug 2022 15:50:46 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 8D70E1A08F0 for ; Sun, 28 Aug 2022 19:50:46 +0000 (UTC) X-FDA: 79850044092.02.73687FE Received: from mail-vs1-f47.google.com (mail-vs1-f47.google.com [209.85.217.47]) by imf08.hostedemail.com (Postfix) with ESMTP id 4975816004E for ; Sun, 28 Aug 2022 19:50:46 +0000 (UTC) Received: by mail-vs1-f47.google.com with SMTP id p6so6510706vsr.9 for ; Sun, 28 Aug 2022 12:50:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=+v2zwEcOJT455DYq2PDJ2m5npdfWrDTIt86gNrYfAfc=; b=oRjN+/A3WWnFFM0BPcVi0Rc5jIQqm8bbut4KMQbcLOXSVdF/l7ANaTrz/m76a7yhgk sTfbpElKdUCXDUF2HcblLXwtEks/hAH38xZrjJCRRloAibkhv6IPg9yWoJfAOyfoEOth n3Q4cOT2p8W83ogFv9rr080RipI7MCgzhsYRiOaxuRyb/Fumw3jRGN9WtM/J45Oftz0j w/ISKLFvjb5v+z4OgCig/n3W4rRtb15AlKLVLUpqNh3uQ3e7zzkRcoIR15avWeNmG/vx HdjoQ2KTVAUCRbtrXXPWj/TIMqOT5r6amvVOUWLumM58u3ltyHbMb/6BRHqfz1/yC+oR PNYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=+v2zwEcOJT455DYq2PDJ2m5npdfWrDTIt86gNrYfAfc=; b=QU/B9lMAX4Se6ufptjru1pbOK1YnM+ecR1zb0b6tQRauJeL+QGY8esazAhnVSzB0b7 kF9XSejbPJj/UDDrOBNT5+/jlN0paHfEDNIRtXF6vGBdLdEdUcaUvW8pawCPMGpb2Z1T 0k+1HKP0vNgFAaWrCVuc2HWn//yN6Uew1dNjNEkZ/ZBuOhTs/jY1MA72dXlcXJQR2pVq H28mruD5ccRTY0EDtBvLyl+ELtyHMyUK5Zi5mebu2/ASDB52E82aKGNShJWIHPBoHo5A GXKz6BgPyonf+5wGUQoqMMbOS9ChMtYa/rn5CiuB1T55szTSa0lNF28BnSreykVKpjIu U65w== X-Gm-Message-State: ACgBeo0v9phFM/QgIUm6pKhq/scTF2rAneXKoAyNise6jUDJ744GEq3g v/0cyPtRmYA6HS8XJTHfVFAZi1jNl9uuyMObvKN5QQ== X-Google-Smtp-Source: AA6agR4zBYiEXFieLaETyfJ8Rsax+YVm7x98jgZmyuW38pyWvv0P0eVR13oXtS3rt8TGtr2WBnmNel188rmvTCCwRYk= X-Received: by 2002:a67:b009:0:b0:38a:e0f2:4108 with SMTP id z9-20020a67b009000000b0038ae0f24108mr2599399vse.9.1661716245413; Sun, 28 Aug 2022 12:50:45 -0700 (PDT) MIME-Version: 1.0 References: <20220531223100.510392-1-surenb@google.com> <20220531223100.510392-2-surenb@google.com> <20220822152119.96d40c884078229ee3e6b25e@linux-foundation.org> <20220822154822.366a9e4527b748cf99d98637@linux-foundation.org> <20220822161603.9e19edfe2daaea3bf591910a@linux-foundation.org> In-Reply-To: From: Yu Zhao Date: Sun, 28 Aug 2022 13:50:09 -0600 Message-ID: Subject: Re: [PATCH RESEND v2 2/2] mm: delete unused MMF_OOM_VICTIM flag To: Michal Hocko Cc: Andrew Morton , Suren Baghdasaryan , David Rientjes , Matthew Wilcox , Johannes Weiner , Roman Gushchin , Minchan Kim , "Kirill A . Shutemov" , Andrea Arcangeli , brauner@kernel.org, Christoph Hellwig , oleg@redhat.com, David Hildenbrand , Jann Horn , Shakeel Butt , Peter Xu , John Hubbard , shuah@kernel.org, linux-kernel , Linux-MM , linux-kselftest@vger.kernel.org, kernel-team@android.com Content-Type: text/plain; charset="UTF-8" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661716246; a=rsa-sha256; cv=none; b=EcVLAZfZ+BXmhrDefzWMe8lGb0qtaVk/muPQOd5JPRr3R76KP4H2GUCvFb5x909IWB/Ymq fkKAT8XGmpsCt4tg0RT9YgWBa5GkBr9rJv/P1psYSdEZU6AaNbcbLKaU8lPqSRaN0TTKsj grL5SjdUSVYanTwtQovEUMaUB3xAhI0= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="oRjN+/A3"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf08.hostedemail.com: domain of yuzhao@google.com designates 209.85.217.47 as permitted sender) smtp.mailfrom=yuzhao@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661716246; 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=+v2zwEcOJT455DYq2PDJ2m5npdfWrDTIt86gNrYfAfc=; b=FssyDQRg1H4WnR8R5yR0XVT5N7idBPgyJ1lnFXJ+M4KoEL0Sb/v9m6ZUmdwx9+HCi/VRHW SJKe6DZQZapxCTDJ2me5PPltg4ZwPhQ06DggI5Fs0x58tM9uJlPSxYRlg5Nus2aPd8YbbN tZ+ugXjZW6RFTgnnFM/Xss+K4nQa7ck= X-Rspamd-Server: rspam11 X-Rspam-User: X-Rspamd-Queue-Id: 4975816004E Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="oRjN+/A3"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf08.hostedemail.com: domain of yuzhao@google.com designates 209.85.217.47 as permitted sender) smtp.mailfrom=yuzhao@google.com X-Stat-Signature: 4o4xyzxd3h1q6cp5oezf7n9uj8zestfr X-HE-Tag: 1661716246-31992 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Aug 23, 2022 at 2:36 AM Michal Hocko wrote: > > On Mon 22-08-22 17:20:17, Yu Zhao wrote: > > On Mon, Aug 22, 2022 at 5:16 PM Andrew Morton wrote: > > > > > > On Mon, 22 Aug 2022 16:59:29 -0600 Yu Zhao wrote: > > > > > > > > > @@ -4109,7 +4109,7 @@ static int walk_pud_range(p4d_t *p4d, unsigned > > > > > > long start, unsigned long end, > > > > > > > > > > > > walk_pmd_range(&val, addr, next, args); > > > > > > > > > > > > - if (mm_is_oom_victim(args->mm)) > > > > > > + if (test_bit(MMF_OOM_REAP_QUEUED, &args->mm->flags)) > > > > > > return 1; > > > > > > > > > > > > /* a racy check to curtail the waiting time */ > > > > > > > > > > Oh. Why? What does this change do? > > > > > > > > The MMF_OOM_REAP_QUEUED flag is similar to the deleted MMF_OOM_VICTIM > > > > flag, but it's set at a later stage during an OOM kill. > > > > > > > > When either is set, the OOM reaper is probably already freeing the > > > > memory of this mm_struct, or at least it's going to. So there is no > > > > need to dwell on it in the reclaim path, hence not about correctness. > > > > > > Thanks. That sounds worthy of some code comments? > > > > Will do. Thanks. > > I would rather not see this abuse. I understand where you're coming from, however, I don't share this POV. I see it as cooperation -- the page reclaim and the oom/reaper can't (or at least shouldn't) operate in isolation. > You cannot really make any > assumptions about oom_reaper and how quickly it is going to free the > memory. Agreed. But here we are talking about heuristics, not dependencies on certain behaviors. Assume we are playing a guessing game: there are multiple mm_structs available for reclaim, would the oom-killed ones be more profitable on average? I'd say no, because I assume it's more likely than unlikely that the oom reaper is doing/to do its work. Note that the assumption is about likelihood, hence arguably valid. > If this is really worth it (and I have to say I doubt it) then > it should be a separate patch with numbers justifying it. I definitely can artificially create a test case that runs oom a few times per second, to prove this two-liner is beneficial to that scenario. Then there is the question how much it would benefit the real-world scenarios. I'd recommend keeping this two-liner if we still had mm_is_oom_victim(), because it's simple, clear and intuitive. With MMF_OOM_REAP_QUEUED, I don't have a strong opinion. Since you do, I'll just delete it.