From patchwork Tue Jul 10 09:43:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10516681 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 301206020F for ; Tue, 10 Jul 2018 09:43:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D910286EE for ; Tue, 10 Jul 2018 09:43:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10C2928843; Tue, 10 Jul 2018 09:43:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92CD5286EE for ; Tue, 10 Jul 2018 09:43:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D20046B0006; Tue, 10 Jul 2018 05:43:46 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CD0796B0008; Tue, 10 Jul 2018 05:43:46 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BC04F6B000A; Tue, 10 Jul 2018 05:43:46 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by kanga.kvack.org (Postfix) with ESMTP id 5D32A6B0006 for ; Tue, 10 Jul 2018 05:43:46 -0400 (EDT) Received: by mail-ed1-f71.google.com with SMTP id n2-v6so8413371edr.5 for ; Tue, 10 Jul 2018 02:43:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:date:from:to :cc:subject:message-id:references:mime-version:content-disposition :in-reply-to:user-agent; bh=4KpfUjuj9wLIQQyYZE+KTzjsfWiPHecLklMefx9vD+k=; b=DGL6N/dRKqCJ8o/LzCUVLqW1rVyiQLTusv6mGzDQaDOzeWn3m9BYaEfl5JbDBKCJhe NKbdEYGpXRLzmnxvodY3rl8lEFabt04JjQS+1NO41L+nerUSJhe8H6+aNgRfoFtR1/Rh q+tXom+Mz6sm2H/UAGzLlRjQzYGgX5HINcc5Zi8wInViuXmcN+xo1cwiIBgOCRMexp+m RHrgCIDZHKY6d9TuIe4X76Un1tTR9S0DF/PbBrGd7cjEVOMrpmS6fOlSMMM4/Td/voDb EWeOji9fvStZbVkkK34baJo88Ewez2SY6LHb5qyPULTbUcMy6gAprm+WERVx7+oVdU2X byFA== X-Original-Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning mhocko@kernel.org does not designate 195.135.220.15 as permitted sender) smtp.mailfrom=mhocko@kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Gm-Message-State: APt69E3YZ1VeZX4giXyb3GTWZQ7uwEcMwGYLMYQ0BYJW/aFLRfywPk2v SgZbX7fNjkzgi9GMpps2+UWpz2+/f5/c0Yt6WzZbCerLJqobaO6Y2+PqICxwIgFUikiZrtjPzOK qLclaFnEax1VHsDhBLUQ2dI8eLYaMi4k6i8OAqm6xItpXbsyLaf7OkDn7V2JfT0Y= X-Received: by 2002:aa7:d9d7:: with SMTP id v23-v6mr25880650eds.300.1531215825942; Tue, 10 Jul 2018 02:43:45 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdtxg3SzuZssjO0+74W5/UcNLTr0dsPGDwd1vRSyvUX/OH/SrzE85gZrTjsrazktSvCr0eG X-Received: by 2002:aa7:d9d7:: with SMTP id v23-v6mr25880589eds.300.1531215824765; Tue, 10 Jul 2018 02:43:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531215824; cv=none; d=google.com; s=arc-20160816; b=oO8Vt33RTgRHkaNvBrcXVyi8E8sL23Jc8wK+L3m/Tg+FqhsY8b2s8v/fkGmzJ93ftR ++8O6R4iTC8DOnE0LqH3LkUY8aPjNHHXiUgZUkBmE7zWNqadoJDC/44N1eQHsd5V1hfF GxHpYS3W74IPbOmp7CvdXmSPVqzjruYQRvBAD4qlsMnyMRaZp1U6O1CeJK0w+sl/bXNT 1NmrNp1YzptPllqkZG1V/xdcREMiUda02vvs0XaERPWuBuwrkwfCovm33R4JJpHc5el+ KH4oK6ayZma7tWP5fgzi97316s2E9dKRh7pR+AV0jbamKuRYIFU5rOtFIuiRyVW0wJ6d J1sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:arc-authentication-results; bh=4KpfUjuj9wLIQQyYZE+KTzjsfWiPHecLklMefx9vD+k=; b=M9VxSdyVh3tu5H3sPPUfbmWQTgJ1ZxMNmcFpM22mj3WXBxIEOSrpdyFMgU7920+FiK SCoEwu+FouHTeBNTndtBp/63OBYl1KhN5F67S+uWV5Sa07/QVUs+iEeS1VESkw1wNiha dqq3yi4kp43I7VCz8aDW7gzLFZRb52+yh54UjxGUtlWek3VUO9487LT0+utj0UMNcnC+ w8nVoNM6T+FXkjvkgsJU2ygaKth0EwMLVbftjg3hGviOb6ZdA/KmLMy6I+Tdj09a/L7w ELaBDyS6OGhfVNJy6ijCF9A63I0rYDt6SyBMrbzol7YHFI+xO9+Y40nsRjJDLrmr/t6C Rldg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning mhocko@kernel.org does not designate 195.135.220.15 as permitted sender) smtp.mailfrom=mhocko@kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from mx1.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id m5-v6si5397649edm.189.2018.07.10.02.43.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Jul 2018 02:43:44 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning mhocko@kernel.org does not designate 195.135.220.15 as permitted sender) client-ip=195.135.220.15; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning mhocko@kernel.org does not designate 195.135.220.15 as permitted sender) smtp.mailfrom=mhocko@kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id DC96DAD2C; Tue, 10 Jul 2018 09:43:43 +0000 (UTC) Date: Tue, 10 Jul 2018 11:43:41 +0200 From: Michal Hocko To: David Rientjes Cc: Andrew Morton , Tetsuo Handa , linux-mm@kvack.org, LKML Subject: Re: [PATCH] mm, oom: remove sleep from under oom_lock Message-ID: <20180710094341.GD14284@dhcp22.suse.cz> References: <20180709074706.30635-1-mhocko@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.0 (2018-05-17) 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: X-Virus-Scanned: ClamAV using ClamSMTP On Mon 09-07-18 15:49:53, David Rientjes wrote: > On Mon, 9 Jul 2018, Michal Hocko wrote: > > > From: Michal Hocko > > > > Tetsuo has pointed out that since 27ae357fa82b ("mm, oom: fix concurrent > > munlock and oom reaper unmap, v3") we have a strong synchronization > > between the oom_killer and victim's exiting because both have to take > > the oom_lock. Therefore the original heuristic to sleep for a short time > > in out_of_memory doesn't serve the original purpose. > > > > Moreover Tetsuo has noticed that the short sleep can be more harmful > > than actually useful. Hammering the system with many processes can lead > > to a starvation when the task holding the oom_lock can block for a > > long time (minutes) and block any further progress because the > > oom_reaper depends on the oom_lock as well. > > > > Drop the short sleep from out_of_memory when we hold the lock. Keep the > > sleep when the trylock fails to throttle the concurrent OOM paths a bit. > > This should be solved in a more reasonable way (e.g. sleep proportional > > to the time spent in the active reclaiming etc.) but this is much more > > complex thing to achieve. This is a quick fixup to remove a stale code. > > > > Reported-by: Tetsuo Handa > > Signed-off-by: Michal Hocko > > This reminds me: > > mm/oom_kill.c > > 54) int sysctl_oom_dump_tasks = 1; > 55) > 56) DEFINE_MUTEX(oom_lock); > 57) > 58) #ifdef CONFIG_NUMA > > Would you mind documenting oom_lock to specify what it's protecting? What do you think about the following? diff --git a/mm/oom_kill.c b/mm/oom_kill.c index ed9d473c571e..32e6f7becb40 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -53,6 +53,14 @@ int sysctl_panic_on_oom; int sysctl_oom_kill_allocating_task; int sysctl_oom_dump_tasks = 1; +/* + * Serializes oom killer invocations (out_of_memory()) from all contexts to + * prevent from over eager oom killing (e.g. when the oom killer is invoked + * from different domains). + * + * oom_killer_disable() relies on this lock to stabilize oom_killer_disabled + * and mark_oom_victim + */ DEFINE_MUTEX(oom_lock); #ifdef CONFIG_NUMA