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 0D9E5C433EF for ; Fri, 22 Apr 2022 15:38:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6B6758D0001; Fri, 22 Apr 2022 11:38:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 664876B0096; Fri, 22 Apr 2022 11:38:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 507988D0001; Fri, 22 Apr 2022 11:38:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id 3989B6B0095 for ; Fri, 22 Apr 2022 11:38:50 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id CC00F120600 for ; Fri, 22 Apr 2022 15:38:49 +0000 (UTC) X-FDA: 79384922778.11.0A565A3 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf31.hostedemail.com (Postfix) with ESMTP id 4CC652002B for ; Fri, 22 Apr 2022 15:38:45 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id CF9391F745; Fri, 22 Apr 2022 15:38:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1650641927; 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=QWBm9KSaL64G4heSBDY5StN85oWFBXv4LEjPALb3118=; b=Pr3jiyHC7XSbaiUzSjGuFFjBeUkubKp5yAodSeHJX8dVABn45GJSEnV8B3CD25gtIAWEWY 2thQgsVC45m8/e+bXE2tBPhmBntM76EwI8dr4mRd9DdbTGrQPD4uzz0CAyL9FBrYC2+CqA aJsURDkmtyYs7bbSfeiHdSuoLSKBa70= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 83B022C141; Fri, 22 Apr 2022 15:38:47 +0000 (UTC) Date: Fri, 22 Apr 2022 17:38:44 +0200 From: Michal Hocko To: Nico Pache Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, David Rientjes , Andrea Arcangeli Subject: Re: [RFC 3/3] exit: Check for MMF_OOM_SKIP in exit_mmap Message-ID: References: <20220421190533.1601879-1-npache@redhat.com> <20220421190533.1601879-4-npache@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220421190533.1601879-4-npache@redhat.com> Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=Pr3jiyHC; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf31.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 4CC652002B X-Stat-Signature: 1e31e5oara38zk3howydi46jxw66r8jg X-HE-Tag: 1650641925-679466 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 Thu 21-04-22 15:05:33, Nico Pache wrote: > The MMF_OOM_SKIP bit is used to indicate weather a mm_struct can not be > invalided or has already been invalided. exit_mmap currently calls > __oom_reap_task_mm unconditionally despite the fact that the oom reaper > may have already called this. > > Add a check for the MMF_OOM_SKIP bit being set in exit_mmap to avoid > unnessary calls to the invalidate code. Why do we care about this? > A slight race can occur on the MMF_OOM_SKIP bit that will still allow > this to run twice. My testing has shown an ~66% decrease in double calls > to _oom_reap_task_mm. > > Fixes: 27ae357fa82b ("mm, oom: fix concurrent munlock and oom reaper unmap, v3") I do not see this would be fixing anything. > Cc: David Rientjes > Cc: Michal Hocko > Cc: Andrea Arcangeli > Signed-off-by: Nico Pache > --- > mm/mmap.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/mm/mmap.c b/mm/mmap.c > index a2968669fd4e..b867f408dacd 100644 > --- a/mm/mmap.c > +++ b/mm/mmap.c > @@ -3113,7 +3113,8 @@ void exit_mmap(struct mm_struct *mm) > /* mm's last user has gone, and its about to be pulled down */ > mmu_notifier_release(mm); > > - if (unlikely(mm_is_oom_victim(mm))) { > + if (unlikely(mm_is_oom_victim(mm)) && > + !test_bit(MMF_OOM_SKIP, &mm->flags)) { > /* > * Manually reap the mm to free as much memory as possible. > * Then, as the oom reaper does, set MMF_OOM_SKIP to disregard > -- > 2.35.1 -- Michal Hocko SUSE Labs