Received: by 10.213.65.68 with SMTP id h4csp669921imn; Wed, 4 Apr 2018 05:24:24 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+JRTVnmdzu9osMacSt5dvDNVLIs/vTOpd0bZ17qvR7Ibk8uZt1q3JqBezPq6+j3GLzetXt X-Received: by 10.101.76.77 with SMTP id l13mr11852041pgr.192.1522844664856; Wed, 04 Apr 2018 05:24:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522844664; cv=none; d=google.com; s=arc-20160816; b=kIF3JZdu9J9O50cZPc9PZb98nMM9TKy6RZYbW4mUHR+ULowwbtnbUydzAxcLquSbmz 9/q8uoH4sdAYaPxS0t6YLAOjyMnFDLORPIdclRFk2NV/eautiVHRNz61voGphgAbYBWx WJ2VvEQ7Mf9g42ViztCipLhd6x30M9PceJdW7Mh/2xdyB8yItnmMp+8pxb6a4ZZNLyxB DC85qDijZ6aUTv77QI848qWvRriFkwWgHbfu0t6bkxp1GKvovHg93fjCKK5LuFZD69b1 WCXsff7inTyveLZL3dGbwLgzN1JdEilHek9mn7h3kvfHoSMSYKPqHCYJtXDuHVj0hg1p g/SA== 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=0zVFdCdqWdoh1ft6FijTPhbNHTHRLtAtuuFB4fSHOVc=; b=cNJDHe6fBGEU4QsHAeySgsExGIFMlmD1Tr/aUJgIl5yi9IVNR8u1IyuV2khXvAtCxD qsmRJPCKaMfdpkisQqAHWT5sfRLSpIwDFzVpCH8cxJlnCwxdR3DmTAc5Nda6VGkoytfO iDr/nZIGpTUM7AEIF/pcFUu+NZFm+NpDdPMdZVYWKOcrTXgzjesn/M/QCwrvKPnENCMJ v3FDCEBekNSsDiSrFlBY10jplvRpi0t4/VR1RyCvdH0TMMTVWPYXfYFy/umtun2/+SOG RJp84NNuuJluQwDC70aVvgxGHKWGO5+RVRYYAV92te1m/SzGOB4WAMQ5i/t2haABDIsA WGyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=RkY0ywGO; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h6-v6si2784441pll.726.2018.04.04.05.24.10; Wed, 04 Apr 2018 05:24:24 -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=@google.com header.s=20161025 header.b=RkY0ywGO; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751384AbeDDMVx (ORCPT + 99 others); Wed, 4 Apr 2018 08:21:53 -0400 Received: from mail-io0-f181.google.com ([209.85.223.181]:33481 "EHLO mail-io0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751117AbeDDMVv (ORCPT ); Wed, 4 Apr 2018 08:21:51 -0400 Received: by mail-io0-f181.google.com with SMTP id p139so2068540iod.0 for ; Wed, 04 Apr 2018 05:21:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=0zVFdCdqWdoh1ft6FijTPhbNHTHRLtAtuuFB4fSHOVc=; b=RkY0ywGOPwQDd41D3tUPanv+gI9g9o5tAbuH4LErT6Z3cmYbyEjieNwRrth4TX69dD JeZnk8v6+106S1kcWDo+zCrCiqrhS1/i0qcgl0Mu+wlcWpJrqhWMcJIDB4PalR1XMnQ8 8gvDhbTEiBZNYyUKqyN8VIo0e4KD5i3JcnN+dnF5XZSBUgOSyqBilgYh53TUREV0qVbx 9FProi0YPjzjDqrH8H2auBd2JGUalw1VaDeJqIBvWUL6EbcHPezi/UbLCximKcpUQnWx q+a6PE23eKw1vDlbki5vKFeBOtTUkBNflGqoPZTTYqVF72B1SIwMWZAP5e3H+B1xz456 1wPw== 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=0zVFdCdqWdoh1ft6FijTPhbNHTHRLtAtuuFB4fSHOVc=; b=ATgp8BVkWN3B0w/mAS6A7b56pImk41Q4tst9oMz39PL7zPMWccW1bQm608Vnoipeh0 cSS1zCRUQyV/C9ptjSDHyYsyXMBtz4sqinN2wSVUaRh2s9Tets+5nuz7+cJ25llm47wF 5GzIjPUHlj/WtnaLX2Wb6ZmudSRmSvwOawPkYv8ZT1kgPmch8T0QVFYN4C7M8rUrLzt3 Uf4UbqJjrY26OapafHO/oRza6xrqb8DMyuxiNWvcHYSVyN5hJj/jD2R0BWEcHGk8L5HE KYTT6Sr5D3YyzSKxWz39fBuLlgCUo2Howkui+LeKGdGCvTulVAbn61YlYTNLdadQB6J9 Lalg== X-Gm-Message-State: AElRT7GNCDrQl7YnB4cPFvhSfJI6m7tkO22U5Tojk7z2v1txzCzagNIc 68K+avWk7UD4EMigjqR0hSUItuYwnZIVSfvRosj4Og== X-Received: by 10.107.131.194 with SMTP id n63mr16935613ioi.268.1522844510513; Wed, 04 Apr 2018 05:21:50 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.11.158 with HTTP; Wed, 4 Apr 2018 05:21:49 -0700 (PDT) In-Reply-To: <20180404062039.GC6312@dhcp22.suse.cz> References: <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> <20180403101753.3391a639@gandalf.local.home> <20180403161119.GE5501@dhcp22.suse.cz> <20180403185627.6bf9ea9b@gandalf.local.home> <20180404062039.GC6312@dhcp22.suse.cz> From: Joel Fernandes Date: Wed, 4 Apr 2018 05:21:49 -0700 Message-ID: Subject: Re: [PATCH v1] kernel/trace:check the val against the available mem To: Michal Hocko Cc: Steven Rostedt , Zhaoyang Huang , Ingo Molnar , LKML , kernel-patch-test@lists.linaro.org, Andrew Morton , "open list:MEMORY MANAGEMENT" , 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 Tue, Apr 3, 2018 at 11:20 PM, Michal Hocko wrote: > On Tue 03-04-18 18:56:27, Steven Rostedt wrote: > [...] >> From your earlier email: >> >> > Except that it doesn't work. si_mem_available is not really suitable for >> > any allocation estimations. Its only purpose is to provide a very rough >> > estimation for userspace. Any other use is basically abuse. The >> > situation can change really quickly. Really it is really hard to be >> > clever here with the volatility the memory allocations can cause. >> >> Now can you please explain to me why si_mem_available is not suitable >> for my purpose. > > Several problems. It is overly optimistic especially when we are close > to OOM. The available pagecache or slab reclaimable objects might be pinned > long enough that your allocation based on that estimation will just make > the situation worse and result in OOM. More importantly though, your > allocations are GFP_KERNEL, right, that means that such an allocation > will not reach to ZONE_MOVABLE or ZONE_HIGMEM (32b systems) while the > pagecache will. So you will get an overestimate of how much you can > allocate. Yes, but right now it is assumed that there is all the memory in the world to allocate. Clearly an overestimate is better than that. Right now ftrace will just allocate memory until it actually fails to allocate, at which point it may have caused other processes to be likely to OOM. As Steve pointed out, it doesn't need to be accurate but does solve the problem here.. (or some other similar method seems to be needed to solve it). > > Really si_mem_available is for proc/meminfo and a rough estimate of the > free memory because users tend to be confused by seeing MemFree too low > and complaining that the system has eaten all their memory. I have some By why is a rough estimate not good in this case, that's what I don't get. > skepticism about how useful it is in practice apart from showing it in > top or alike tools. The memory is simply not usable immediately or > without an overall and visible effect on the whole system. Sure there can be false positives but it does reduce the problem for the most part I feel. May be we can use this as an interim solution (better than leaving the issue hanging)? Or you could propose a solution of how to get an estimate and prevent other tasks from experiencing memory pressure for no reason. Another thing we could do is check how much total memory there is on the system and cap by that (which will prevent impossibly large allocations) but that still doesn't address the problem completely. thanks, - Joel