Received: by 10.213.65.68 with SMTP id h4csp814869imn; Wed, 4 Apr 2018 07:44:35 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/PFVU0h5wghsBI59/+R6PAqfLfnv+Kw3LLd5ucNHmYv9kPbkw98LTMh39RKxpyw6WmoTr7 X-Received: by 2002:a17:902:bf47:: with SMTP id u7-v6mr12793821pls.133.1522853075489; Wed, 04 Apr 2018 07:44:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522853075; cv=none; d=google.com; s=arc-20160816; b=d5d9tuFTVJuGr8f1C1gXIOrK+2HXlM63kyFZhJH71C197018ZHaHOnsvTMh53qaXkt +4tXAhSNlzPOLrof7mjOJRCfdjzNKPUMrsIrdE23qk4smWxvxUHhzKJGEnyIrh8H5hfe SDoxlSC0z3HHPSIvWTfhh/rE0TquahwyfuXsphhLLzUiC0f3xQ57FH4vrtLM8llLr8H3 BX2KoUlnVlY5eF4Dy2QGHKefdOl+ZGwtEVJHI8/TOA3Xk634Xjt8sTbCyU0Za0yzZ04E 9sLhmfXllQyx/cJL39L6gCwBQ+4H4jKqGCCwLI6329t7QH0qcJQtBURKTbw88ZmIn+MV hxyQ== 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=CnSHjkPMUr9KpmUkYhU/UHwBcSDiga1dxijTjkcQRfw=; b=U0TnN9iYaCAitKg6rQnHeSyQWTvQiuCzjvgnAYLIvPfoXWphJKdHf6obNwZO9XGYF/ XXEMOQfswxtVi802AOfeyvxYH4qFP693UVBwjjLCBjXROQW6aW1Liz1k7mUkt+1v/3h4 NfdR8Nl04WiLo1wlD0UG5AIn+V46B7T0FsOUqoGG9qhETdZZhtQcSBobREI3VHxVh9Sa uMwsBRdRiWceMpTx3Z10giBR4zZjfW24M4GU4qfo77uFn2DjVyycNN3ppU64Hk4oH7+x KBpI9k/U8/5kxaxfEFuO8r+1B7yLN8h2vjcOEkFwVN07QCXfiQTypLV6kFfhjFwv1Lo4 vdNw== 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 h2si3710103pgq.604.2018.04.04.07.44.20; Wed, 04 Apr 2018 07:44:35 -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 S1751417AbeDDOnA (ORCPT + 99 others); Wed, 4 Apr 2018 10:43:00 -0400 Received: from mx2.suse.de ([195.135.220.15]:34512 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751247AbeDDOm7 (ORCPT ); Wed, 4 Apr 2018 10:42:59 -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 73548AD1E; Wed, 4 Apr 2018 14:42:57 +0000 (UTC) Date: Wed, 4 Apr 2018 16:42:55 +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: <20180404144255.GK6312@dhcp22.suse.cz> References: <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> <20180404085901.5b54fe32@gandalf.local.home> <20180404141052.GH6312@dhcp22.suse.cz> <20180404102527.763250b4@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180404102527.763250b4@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 Wed 04-04-18 10:25:27, Steven Rostedt wrote: > On Wed, 4 Apr 2018 16:10:52 +0200 > Michal Hocko wrote: > > > On Wed 04-04-18 08:59:01, Steven Rostedt wrote: > > [...] > > > + /* > > > + * Check if the available memory is there first. > > > + * Note, si_mem_available() only gives us a rough estimate of available > > > + * memory. It may not be accurate. But we don't care, we just want > > > + * to prevent doing any allocation when it is obvious that it is > > > + * not going to succeed. > > > + */ > > > + i = si_mem_available(); > > > + if (i < nr_pages) > > > + return -ENOMEM; > > > + > > > > > > Better? > > > > I must be really missing something here. How can that work at all for > > e.g. the zone_{highmem/movable}. You will get false on the above tests > > even when you will have hard time to allocate anything from your > > destination zones. > > You mean we will get true on the above tests? Again, the current > method is to just say screw it and try to allocate. No, you will get false on that test. Say that you have a system with large ZONE_MOVABLE. Now your kernel allocations can fit only into !movable zones (say we have 1G for !movable and 3G for movable). Now say that !movable zones are getting close to the edge while movable zones are full of reclaimable pages. si_mem_available will tell you there is a _lot_ of memory available while your GFP_KERNEL request will happily consume the rest of !movable zones and trigger OOM. See? [...] > I'm looking for something where "yes" means "there may be enough, but > there may not be, buyer beware", and "no" means "forget it, don't even > start, because you just asked for more than possible". We do not have _that_ something other than try to opportunistically allocate and see what happens. Sucks? Maybe yes but I really cannot think of an interface with sane semantic that would catch all the different scenarios. -- Michal Hocko SUSE Labs