Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3072983imm; Mon, 16 Jul 2018 21:15:31 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdboBb1E9S8WCLjRQPWv61B1SiPP2apJzNsJAKFzapDOP0IBa4+W80KVmrF5KAX7M9OPEgG X-Received: by 2002:a65:4304:: with SMTP id j4-v6mr18427825pgq.109.1531800931586; Mon, 16 Jul 2018 21:15:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531800931; cv=none; d=google.com; s=arc-20160816; b=Oli8zgEIdGwblaYSPYQV5lYAyOEd8lht4ka5VB9hZhpECk5BPW0Jf1M4MvZ2rWL3z3 g0RJ3LZqUSEm1V/yPjWkgLliGSK84I2MVU071UJGbO2JekLI28y1eMj09gRjGvrg//lg 8CJ/Nsvq68j2ykrd990DmQWiE4y2lZzCO3AWFM3WUSkc9Xoli3ZJsggAYGnAbyyZBvip OxwHhJFIbhPj1Jzt1u2+yVk20ajmQDn6+RywaqhgxuN/4OkWFkM+ol0NeKxgGP/jQW0N Aqkx+Kk5R8E9JQpDF3rM/03aPx2DOyco6c/QUSOUl17yQ5iZ0L4Zjs5PRJhTTdzNZSI0 tLZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=QlpvFHK8aHZhIPNe3gj8CUGLLWno8RSEqV69yA+7fPg=; b=z2tH7+adUEm0OsXZa/pOSBB8F3zel+Rc1ACn0BclNIkW10K1s/YImoSWIw09Ryfg7q HwFENBRtlBN+4ay3p3GR+IATOFRXIEPWDyFYyBnbU36wDi/s0aTU4zkGJSp08zKvbni9 uTImNWJIUYd3b5KMJNWIRAG4q4wAaxGfcUhsc1Md76mVxLaA/xh+ZCRWOemcV2iyj7fW kcftoYzkSklsG2wlSZZWA1utqamPfD+/7QAvXyuHah/DzUORqA7kNELczVFJAOhmMKJL nmfXEo7i17cqSsmtwssCicRP3zsyHYGvh+UeUYfFjlXS+lmwJihU4WpVhdg9J7NLQY0O 0dTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=IKvgMznO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y123-v6si34365564pfc.302.2018.07.16.21.15.16; Mon, 16 Jul 2018 21:15:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=IKvgMznO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728309AbeGQEpK (ORCPT + 99 others); Tue, 17 Jul 2018 00:45:10 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:44454 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727796AbeGQEpJ (ORCPT ); Tue, 17 Jul 2018 00:45:09 -0400 Received: by mail-pf0-f195.google.com with SMTP id k21-v6so2471608pff.11 for ; Mon, 16 Jul 2018 21:14:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=QlpvFHK8aHZhIPNe3gj8CUGLLWno8RSEqV69yA+7fPg=; b=IKvgMznOi1AuC44Re2wJ1ffS/gLU8WCOdnm0unSdKPJrqisiQGpE/Wg8Vcb5LiT4+d RA0ceRNpX2wqCaKTGrpDaltU85AhwFIu6rB8gjNB8AOQgHPjZ6+vETjX/UlyHlhd0yfo tioITRj7v5dD7E37GiwxR/lgwTqh/viviDnCADHAIV5m0mNPcK2LDVMAazHAJDfSwwnA 7h1QR69pEQibbw+UFh+gaPUDaKrW5fW0eIfVr59bkb/wuyrxVH/aCcJKRl0ZFTmUhmYS OVf3CKFu7u2bd1KPoIOXlc8Nswhs7QvJ/tOJEUyVDcd+TXRQvXXaYYN7fNMQKU4GIPH7 W86A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=QlpvFHK8aHZhIPNe3gj8CUGLLWno8RSEqV69yA+7fPg=; b=efc2/3wR8mnMdNbAprD4QkrVcpMFV8rH8JBeKjA53UGcIEX9FSU4GAyU18C7LtMPxJ FgVR8TevW9t9l7Uo1p08OOegAOfUurOCdT1fUoIknqkV4n8jO9MMtHrhYcshhWo01FOw 4iCIswdQKrgfFgL0Utidfp/mbClvanlEpn4wV4MakdlhdXDna67YvWkPwooXisZtADkj EqyOYzAla7S5OuFUKG30bMQWjbQqnbACaZDd8w8xvf+hXs//o0uGstGbIPdVq+/xAgZW DZqCAwJCePeOt3SzAg9CzMMXysF3DqF/XjEb8G/KEIWqOTJFnA/9NZNL+l0oWhlZlJz0 EKMw== X-Gm-Message-State: AOUpUlGZI1FtD8GzkDgU03okCiE/JJZR3S/qpRQdqtWm/L2KDY0Y1vA6 GStXlQS62L4+I6lkmjYY94RGyA== X-Received: by 2002:a63:8dca:: with SMTP id z193-v6mr5627pgd.228.1531800871059; Mon, 16 Jul 2018 21:14:31 -0700 (PDT) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id 16-v6sm11885341pfo.164.2018.07.16.21.14.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Jul 2018 21:14:30 -0700 (PDT) Date: Mon, 16 Jul 2018 21:14:29 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Michal Hocko cc: Andrew Morton , Tetsuo Handa , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [patch -mm] mm, oom: remove oom_lock from exit_mmap In-Reply-To: <20180713142612.GD19960@dhcp22.suse.cz> Message-ID: References: <20180713142612.GD19960@dhcp22.suse.cz> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 13 Jul 2018, Michal Hocko wrote: > > diff --git a/mm/oom_kill.c b/mm/oom_kill.c > > index 0fe4087d5151..e6328cef090f 100644 > > --- a/mm/oom_kill.c > > +++ b/mm/oom_kill.c > > @@ -488,9 +488,11 @@ void __oom_reap_task_mm(struct mm_struct *mm) > > * Tell all users of get_user/copy_from_user etc... that the content > > * is no longer stable. No barriers really needed because unmapping > > * should imply barriers already and the reader would hit a page fault > > - * if it stumbled over a reaped memory. > > + * if it stumbled over a reaped memory. If MMF_UNSTABLE is already set, > > + * reaping as already occurred so nothing left to do. > > */ > > - set_bit(MMF_UNSTABLE, &mm->flags); > > + if (test_and_set_bit(MMF_UNSTABLE, &mm->flags)) > > + return; > > This could lead to pre mature oom victim selection > oom_reaper exiting victim > oom_reap_task exit_mmap > __oom_reap_task_mm __oom_reap_task_mm > test_and_set_bit(MMF_UNSTABLE) # wins the race > test_and_set_bit(MMF_UNSTABLE) > set_bit(MMF_OOM_SKIP) # new victim can be selected now. > This is not the current state of the code in the -mm tree: MMF_OOM_SKIP only gets set by the oom reaper when the timeout has expired when the victim has failed to free memory in the exit path. > Besides that, why should we back off in the first place. We can > race the two without any problems AFAICS. We already do have proper > synchronization between the two due to mmap_sem and MMF_OOM_SKIP. > test_and_set_bit() here is not strictly required, I thought it was better since any unmapping done in this context is going to be handled by whichever thread set MMF_UNSTABLE.