Received: by 10.213.65.68 with SMTP id h4csp378986imn; Tue, 3 Apr 2018 23:25:04 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+ZiaulqBf8gyi/NMn71nRW8ZKkTezBuqEFEcONLcWZ2hf5a2+Nur53fONIbfGkVaowBnnc X-Received: by 2002:a17:902:8482:: with SMTP id c2-v6mr17729558plo.295.1522823104229; Tue, 03 Apr 2018 23:25:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522823104; cv=none; d=google.com; s=arc-20160816; b=BOiJ8vLcsGCqEdWveI/DlFBYDGvLKeTmO9E5cs181/iySgBZ1JtDgMUjjsr9vSYYwN xd43K3Lu6c4dxYGcEk/x228lDLmUMgBbS4ZHcf7AeTtBZ6Y2tIZKFNW5762u51Z7MXVR WnErKjThWd/W+BQ232UizDx3xRNJ1ofIcMvmlLeMpjpia1MjmM3rqDnN0r0HBDQNUV2b 1I7UakfitmWX2SUjA1DIcjh4uK/yHXTvRi5rrXxRYLllY/chKTcgS7+ipLekOTFt+aBv +SAnmo9pmhF2jWwjUkcshPjVIO4Ui6rzZ7lPvO88v/F454hnCLYDhZzqgz8RXJLd0zra RH1g== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=F4kkCrSl/e7uU+CUYX4lGXTJK0+KxMU72G8iYDvtxJU=; b=K7QAWuGuOWwu0bIbxBZwjFp3IhZI7EHPvIRSdKkIHa+CfHuUicLi2L/MicbQAjuziL uHSgkTLc45hVsVuKWSmPBk9RGNxi6KZCYHlzh8Cz60D24oUt55MeCgZEpMhfYhktxVrH LXF48CvCOlj7mVLeZp+MaCZjpIhadg/ef//Y+DRy9+7qQpR7J99un70Yi9rv3EmpB3h2 SYmViPcLyqgko7qNUYdiA3QwlUlBxIOOTv7QcrpR19pRFjC2Qzb+NbDig65pt4JqxDl2 xeKhKgSW52iOX9XCp15ggRuX/Gx3bw7WZ9l2WLLNBviJh/Dl9MkPfAeEH2fKl0sn9LSt qthw== 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 11-v6si2412580plb.658.2018.04.03.23.24.49; Tue, 03 Apr 2018 23:25:04 -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 S1751245AbeDDGXn (ORCPT + 99 others); Wed, 4 Apr 2018 02:23:43 -0400 Received: from mx2.suse.de ([195.135.220.15]:45908 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750711AbeDDGXm (ORCPT ); Wed, 4 Apr 2018 02:23:42 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 55211AFFF; Wed, 4 Apr 2018 06:23:41 +0000 (UTC) Date: Wed, 4 Apr 2018 08:23:40 +0200 From: Michal Hocko To: Zhaoyang Huang Cc: Steven Rostedt , Ingo Molnar , linux-kernel@vger.kernel.org, kernel-patch-test@lists.linaro.org, Andrew Morton , Joel Fernandes , linux-mm@kvack.org, Vlastimil Babka Subject: Re: [PATCH v1] kernel/trace:check the val against the available mem Message-ID: <20180404062340.GD6312@dhcp22.suse.cz> References: <1522320104-6573-1-git-send-email-zhaoyang.huang@spreadtrum.com> <20180330102038.2378925b@gandalf.local.home> <20180403110612.GM5501@dhcp22.suse.cz> <20180403075158.0c0a2795@gandalf.local.home> <20180403121614.GV5501@dhcp22.suse.cz> <20180403082348.28cd3c1c@gandalf.local.home> <20180403123514.GX5501@dhcp22.suse.cz> <20180403093245.43e7e77c@gandalf.local.home> <20180403135607.GC5501@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 04-04-18 10:58:39, Zhaoyang Huang wrote: > On Tue, Apr 3, 2018 at 9:56 PM, Michal Hocko wrote: > > On Tue 03-04-18 09:32:45, Steven Rostedt wrote: > >> On Tue, 3 Apr 2018 14:35:14 +0200 > >> Michal Hocko wrote: > > [...] > >> > Being clever is OK if it doesn't add a tricky code. And relying on > >> > si_mem_available is definitely tricky and obscure. > >> > >> Can we get the mm subsystem to provide a better method to know if an > >> allocation will possibly succeed or not before trying it? It doesn't > >> have to be free of races. Just "if I allocate this many pages right > >> now, will it work?" If that changes from the time it asks to the time > >> it allocates, that's fine. I'm not trying to prevent OOM to never > >> trigger. I just don't want to to trigger consistently. > > > > How do you do that without an actuall allocation request? And more > > fundamentally, what if your _particular_ request is just fine but it > > will get us so close to the OOM edge that the next legit allocation > > request simply goes OOM? There is simply no sane interface I can think > > of that would satisfy a safe/sensible "will it cause OOM" semantic. > > > The point is the app which try to allocate the size over the line will escape > the OOM and let other innocent to be sacrificed. However, the one which you > mentioned above will be possibly selected by OOM that triggered by consequnce > failed allocation. If you are afraid of that then you can have a look at {set,clear}_current_oom_origin() which will automatically select the current process as an oom victim and kill it. -- Michal Hocko SUSE Labs