Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3936960imm; Mon, 25 Jun 2018 07:07:11 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK9UoB9YIZ7yrHSFcKimgb8FqPDEM6Q/0ZgwU7ShLXXX0PyAvAVmpEx821QqcEUiIlgEXVX X-Received: by 2002:a63:69c4:: with SMTP id e187-v6mr10745146pgc.294.1529935631867; Mon, 25 Jun 2018 07:07:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529935631; cv=none; d=google.com; s=arc-20160816; b=1IKE+4mLP3uC7f5JJ+URhZE/Cd29bmFqjvKmZImMI0xab29FyyNQZi2SFLKrzSKWr+ 9QjUQFVf57lbteIWKINhNenLCVe570aDrcdaLqx/0LpphqFT48V6UKEXZzH25cAkbtXG sy5jEZ+ASKWU7KdXQoKRZm0B1FiAIqsV/42MujecLCh0oJncrqY5FIghBjqYe7I5CnPV 4+CYnxibm82Un6xXgZhuRUpwK9mj0g1enWblvNl43giS8XTZuiJ64lHCH1KxecQy+6AX eb2AtswwVurRULKoi4aoRAD/wQUV1Avhcmb6ETMuqFtvHxMnS83niAL+os6/6ISxRZl5 Hc7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=Ygo0HPH38BfsGOKdhmuTEXYtqm+MmflY8eSWZ3paxcE=; b=aaiLO+kH8u/diXcFPS8QIeIln0YoyxuSRQHSCFpliJXeTDdaARzdfsl4FwPKy+zrZB aIif6P2L9/TqL0czox5b4yOrOYPzak0om0cU0RifNGkvSiJCti9QYq1WA7CtGs5r5U2X v4biquj218hRDXkaRjMT+bZVAvXlVgqYts6GfXunpLhlWWf790+GDQjAPc40LCiPAJf6 eOD/kyLzXZnRY1ZmBqlUqRjZz11yEE3VUEwdxmm/3CVGQ5ZyPLvSvRw1uWzv+YTpsNUk RFmQA6Pnu592zxoK1lrdHEH+ywOXsyMx2gBzQGtTSz92+CKuZH45ug3NAXCyD5X9TDVM PW4w== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o9-v6si11597823pgf.135.2018.06.25.07.06.53; Mon, 25 Jun 2018 07:07:11 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934273AbeFYOEH convert rfc822-to-8bit (ORCPT + 99 others); Mon, 25 Jun 2018 10:04:07 -0400 Received: from seldsegrel01.sonyericsson.com ([37.139.156.29]:17882 "EHLO SELDSEGREL01.sonyericsson.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934238AbeFYOEG (ORCPT ); Mon, 25 Jun 2018 10:04:06 -0400 Subject: Re: [PATCH] mm,oom: Bring OOM notifier callbacks to outside of OOM killer. To: Michal Hocko CC: Tetsuo Handa , , , , 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> From: peter enderborg Message-ID: <9a14d554-6470-e0d6-19cc-1ecec17a47c7@sony.com> Date: Mon, 25 Jun 2018 16:04:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180625130756.GK28965@dhcp22.suse.cz> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8BIT Content-Language: en-GB Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. >>>> 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.