Received: by 10.213.65.68 with SMTP id h4csp377034imn; Tue, 3 Apr 2018 23:22:03 -0700 (PDT) X-Google-Smtp-Source: AIpwx49DauxHbII+vm+IB+0/wkXkdM7n7fUFb4X6m+HFf/+7dfk+RRb575Hhin6w8/W8zEC1FkZT X-Received: by 10.99.43.80 with SMTP id r77mr11065651pgr.193.1522822923650; Tue, 03 Apr 2018 23:22:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522822923; cv=none; d=google.com; s=arc-20160816; b=QNWLCB7Uh68eH9iM/PNuoN8mSHxF3AWLvI92MpToLx5NV5kDcsDJNBx9uMKLGht36m h8SrZHK1DE86NahoUzHqFVvUmrGPdvENR6er0iOOXAv9Wj8vOm6ShKhYIRrzhgcjwNrR PGtEErm8dAV/GNAFKfW/yYZVdudC0nwwfFNZcf8eYONQMfCbYpx+vG5/vwrF70ELsoOc 1P4mOVbaojWa2olqT5K1ctcQuBCg5l2S/U5E6Ye6vWUnF5VkPemr9VtPp1TztQRew8Po cl+lMrj631YNRsvkrpl0WAhGLsiGKx9Vcj1JJ+tT9RMqJ3hbi6G1np9SUl7yzj6kUuEV ksqg== 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=Aynas/6t6wu3KWh7DWJFJGXwptpkVUnIuq956PX65mY=; b=MlapTbNBxN8i00R7tiifCwfFHBi71iCj8ZpHbTmXcJZOIw+JBaBEvGruwq1OcWAZg3 WO8ixIpPjEdjcNgEDfmuwhJxmbvACZ6yXq3aH+ovDz13QHxYnvWeCw41F6tLnKu3MHkM m+QWdWNfLu+nKrD0Li2Fcoql5tWuYsAYLdJVdQOs04cZzwmi0IvwnqRV/8D8ABxCzb4g nxIlu1yd0qaCvdypQR28mg1yiFm6uTeysV/KgLRgpMo2p+Rn0b6QCq3qv3pVvpXuouvg /pv/gFNm115sKiaKIhj7A40CUmZUpDzX2HvFqeEni5L1kMQPfVQdeeWETapfxrmqGDiM DsoA== 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 136si2254644pgc.119.2018.04.03.23.21.48; Tue, 03 Apr 2018 23:22:03 -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 S1751654AbeDDGUn (ORCPT + 99 others); Wed, 4 Apr 2018 02:20:43 -0400 Received: from mx2.suse.de ([195.135.220.15]:45459 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751098AbeDDGUl (ORCPT ); Wed, 4 Apr 2018 02:20:41 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 5D687AFFF; Wed, 4 Apr 2018 06:20:40 +0000 (UTC) Date: Wed, 4 Apr 2018 08:20:39 +0200 From: Michal Hocko To: Steven Rostedt Cc: Zhaoyang Huang , 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: <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180403185627.6bf9ea9b@gandalf.local.home> 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 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. 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 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. HTH -- Michal Hocko SUSE Labs