Received: by 10.213.65.68 with SMTP id h4csp516974imn; Wed, 4 Apr 2018 02:30:33 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/be5WmZTK5KGf7A9Dk+jtQiey5V/3CzYn4iJYLj6Gwkud60qfjkVXFI5hb24Wek84MTvCV X-Received: by 10.98.89.70 with SMTP id n67mr13390671pfb.150.1522834233310; Wed, 04 Apr 2018 02:30:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522834233; cv=none; d=google.com; s=arc-20160816; b=eQIwT3gVvL0eZRB4Pfn1PABFB6bMw59CXglWATnH6ERmj1mbFLVBiRYlgX/YXU4ciJ ASC+6GuXvExVf/OsOy9eE+nwXdBHPoLcVKQMM3eEn+Lhsc8iKlG6ijWeVHt0QSL03pww 2Q1aKNRFVVjqAMUNToEiLzBMm4mxSiOqIwZJuA6vggSTnmLz2HsXiz1oPO3AcbIEqZrj /mDs//CdwWIeA8E1DNJfeCE5rHofzIhYpbZwXlfU75Y7qHZ9+Awvd3x0kEnxLcngu5CD Epp4Q+3MKLs1oyQaGxcGCSpAkDFb6XJK6ngkOakm/6RMduYf6jYMdfnwUmHv2RUdRCoK 0DJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=LJyBcVQJsy8GcxvRWwP1F7v+NV+V0mWt9RV1zlsYMxo=; b=mpAfJVSNfo3fk+CysLnGixXIz1KkHm+wspVkvPzMskQ8jNiYStTiJVMCdi6bduutIe s2EQnSd5qyVDTK0GFDQ2amnrYTIzoTzYen3yJDdptHmKH2VJEGq3nxuxkC/EN329oQLy u967oXn8nRw9L/7thyYZgXshc2MytBQjmaUvU5LoaH3n2W2JC1BmnwT8kDbGztLyq1Do 1hs5v1vTlbF/Ft59DWwdvidjaKkELoso78zoxZ36PVTWJKyA+RyWZwFCrqG6bM8yjIBD BtHTIyD69e5tOFLJG/nMDPmW0/jKazHOy1d7oq3ByV6rCVC5p0L8r6OXAdoWYKGHUZA4 U9jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=d9EiI5XJ; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v9-v6si2728969plo.681.2018.04.04.02.30.19; Wed, 04 Apr 2018 02:30:33 -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=@gmail.com header.s=20161025 header.b=d9EiI5XJ; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751017AbeDDJ3O (ORCPT + 99 others); Wed, 4 Apr 2018 05:29:14 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:55767 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750736AbeDDJ3N (ORCPT ); Wed, 4 Apr 2018 05:29:13 -0400 Received: by mail-wm0-f67.google.com with SMTP id b127so38389601wmf.5 for ; Wed, 04 Apr 2018 02:29:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=LJyBcVQJsy8GcxvRWwP1F7v+NV+V0mWt9RV1zlsYMxo=; b=d9EiI5XJlsmEu3tqI8Hf5Qg4K6cnTFmkatd4JIUlStRcQ3OE9P2pOtsYkbqZS0i6BW /hSb8a1t5qx+I680UdklOmaiRF2D8Wa1Xb+vEwPJFxs7ks0d1V0gIwDUglwvlVvcaaif 6oDquBifUs2Z1jz5jYoURLt0LR+EsOaFNnSimDp4LZpDhx/YNoG9Bi0Jem5O3D+f0HEJ P5oPpcb7yV4mv83sSqzJN3a7ASj5pIXAHOSHALR0fwEssoSkq3p6mK/3HIgLISgzwUXC ZsD13gZIo7vZRxjDIjGbJjHRZO6CbMi6/rlJ1RHpAxAcVAFdapYz+apnSytO/264rzKc 8oCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=LJyBcVQJsy8GcxvRWwP1F7v+NV+V0mWt9RV1zlsYMxo=; b=gYDv0iNKWkWCluOkOydyrhKIzsPRbcmJMbHmI3fJ8XJeOqef+ueSTY1d1Fdt/5/4XN KDKUOD2yD2qi+r1mZVNh4s+dwSLZyO1dXuelmhnLwkXTScbQxxvp5Zi4a7TowOtAFNip lCozxPVTvHxALuz6+Ny5flsvbdZWhmd9LkDvS7gI0GVAFwXRCaVGety8xcpO0CT6SXHL 1ZEI3J6pIzH7r5XPhS/8On89L9p/iG6Jsns91rmw1Q6RYPpqQXof34AQuSLHV60GlurN XjE9y0RbvdW8XCIEhV0kV9JZS69fp0QV3NSQv3MvQz9p0MDZMkDTAozXLhJq7yz7HYj5 6tfA== X-Gm-Message-State: ALQs6tDAi2NUzfM1V/Nq9NrQDlqCteWBqV86vIjW7p0wFCopY/BaIFR0 1AmL8xAxn5TNQvlW6a1YoBNRSIljPct1cvEx6YI= X-Received: by 10.80.247.202 with SMTP id i10mr6052571edn.291.1522834152085; Wed, 04 Apr 2018 02:29:12 -0700 (PDT) MIME-Version: 1.0 Received: by 10.80.201.76 with HTTP; Wed, 4 Apr 2018 02:29:11 -0700 (PDT) In-Reply-To: <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> <20180404062340.GD6312@dhcp22.suse.cz> From: Zhaoyang Huang Date: Wed, 4 Apr 2018 17:29:11 +0800 Message-ID: Subject: Re: [PATCH v1] kernel/trace:check the val against the available mem To: Michal Hocko 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 4, 2018 at 2:23 PM, Michal Hocko wrote: > 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. But we can not call the function on behalf of the current process which maybe don't want to be killed for memory reason. It is proper to tell it ENOMEM and let it make further decision. > -- > Michal Hocko > SUSE Labs