Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3945503imm; Mon, 25 Jun 2018 07:15:06 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKxeBoUqdjmZevL72AEXNaA5wpJdvO8kVcxvqEqQaeTzSemO7dXHXJqHPXSuPFjWQwJwxV0 X-Received: by 2002:a62:be0a:: with SMTP id l10-v6mr13024553pff.180.1529936106314; Mon, 25 Jun 2018 07:15:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529936106; cv=none; d=google.com; s=arc-20160816; b=pRTy2LKbzL4c6Z8vpiRvLlCR666w7VUlCv/QGIXaYjBxDsTWBGpQg9EiIw8pzFc7gs 4SEYEtmvdTg1nGUCFxVHl+7BLQrdpVKJ18KbviJLWmFB4aUR/yALemcsE5tjB50+5SHm b/oYetZRnOQAeZ+C/WfezPydDQwhCvgdPJmzlrTLEIqYrQxVahdf26ithwKlhEKoRDqB Kgg84y6m9EU0bePysLyNrnXSXmxETbVwPZ9KmF0utFpX4AoZzVEyDtJDfewUDeGcJwGn HEAa7kcGTl3BNrhdR2z9GA7VE8XWuaD5j0iNRfq5FV9hVfuvNemsHG+/HbKEGPob7X/0 yQjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=kqpW2A2XKF+UotUvo2FTPufmsdTNWWP4s5o29WrdtS0=; b=Q8HCLGi7S/U9KfRBq5B3H0D7mIGw2+IdPWfTj3B7z5MOSOqck5nKu5qJ6HYuyAZKkh OY6FTzmu7nElufBN5r14K/zfDVWZhnkBB23Jyt8aMIpRQUauAfVDH6+o9sKlDP4QbfVc q7DzJ00OjK8kxntoP8H6YgWvpZmULN91YSbFG3FXpn6BSq7sgezYLURlT1bfzbNEQBBG 6cYbdczzDxGEiGQOFoawC7/EMaXp3XokX69DrfyNmlqzSCLvS7tfuxY+0kxlB3z/Ld6c 0gaCAFQGIMZV1Ec6cwXLpE4zD96f3HW1kUo1802MmWRcrBmtifLacPyxJUrVD5rq9OEf kG6w== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k138-v6si498206pfd.23.2018.06.25.07.14.51; Mon, 25 Jun 2018 07:15:06 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934318AbeFYOMt (ORCPT + 99 others); Mon, 25 Jun 2018 10:12:49 -0400 Received: from mx2.suse.de ([195.135.220.15]:54801 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934014AbeFYOMs (ORCPT ); Mon, 25 Jun 2018 10:12:48 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1313FADCC; Mon, 25 Jun 2018 14:12:47 +0000 (UTC) Date: Mon, 25 Jun 2018 16:12:46 +0200 From: Michal Hocko To: peter enderborg Cc: Tetsuo Handa , linux-mm@kvack.org, rientjes@google.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm,oom: Bring OOM notifier callbacks to outside of OOM killer. Message-ID: <20180625141246.GN28965@dhcp22.suse.cz> References: <1529493638-6389-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> <20180620115531.GL13685@dhcp22.suse.cz> <3d27f26e-68ba-d3c0-9518-cebeb2689aec@sony.com> <20180625130756.GK28965@dhcp22.suse.cz> <9a14d554-6470-e0d6-19cc-1ecec17a47c7@sony.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9a14d554-6470-e0d6-19cc-1ecec17a47c7@sony.com> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 25-06-18 16:04:04, peter enderborg wrote: > On 06/25/2018 03:07 PM, Michal Hocko wrote: > > > On Mon 25-06-18 15:03:40, peter enderborg wrote: > >> On 06/20/2018 01:55 PM, Michal Hocko wrote: > >>> On Wed 20-06-18 20:20:38, Tetsuo Handa wrote: > >>>> Sleeping with oom_lock held can cause AB-BA lockup bug because > >>>> __alloc_pages_may_oom() does not wait for oom_lock. Since > >>>> blocking_notifier_call_chain() in out_of_memory() might sleep, sleeping > >>>> with oom_lock held is currently an unavoidable problem. > >>> Could you be more specific about the potential deadlock? Sleeping while > >>> holding oom lock is certainly not nice but I do not see how that would > >>> result in a deadlock assuming that the sleeping context doesn't sleep on > >>> the memory allocation obviously. > >> It is a mutex you are supposed to be able to sleep.  It's even exported. > > What do you mean? oom_lock is certainly not exported for general use. It > > is not local to oom_killer.c just because it is needed in other _mm_ > > code. > > > > It  is in the oom.h file include/linux/oom.h, if it that sensitive it should > be in mm/ and a documented note about the special rules. It is only used > in drivers/tty/sysrq.c and that be replaced by a help function in mm that > do the  oom stuff. Well, there are many things defined in kernel header files and not meant for wider use. Using random locks is generally discouraged I would say unless you are sure you know what you are doing. We could do some more work to hide internals for sure, though. > >>>> As a preparation for not to sleep with oom_lock held, this patch brings > >>>> OOM notifier callbacks to outside of OOM killer, with two small behavior > >>>> changes explained below. > >>> Can we just eliminate this ugliness and remove it altogether? We do not > >>> have that many notifiers. Is there anything fundamental that would > >>> prevent us from moving them to shrinkers instead? > >> @Hocko Do you remember the lowmemorykiller from android? Some things > >> might not be the right thing for shrinkers. > > Just that lmk did it wrong doesn't mean others have to follow. > > > If all you have is a hammer, everything looks like a nail. (I don’t argument that it was right) > But if you don’t have a way to interact with the memory system we will get attempts like lmk.  > Oom notifiers and vmpressure is for this task better than shrinkers. A lack of feature should be a trigger for a discussion rather than a quick hack that seems to work for a particular usecase and live out of tree, then get to staging and hope it will fix itself. Seriously, the kernel development is not a nail hammering. -- Michal Hocko SUSE Labs