Received: by 10.213.65.68 with SMTP id h4csp797254imn; Wed, 4 Apr 2018 07:26:51 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/WOgafJyEGNtKICI5qV+EsubWZ2jq8B6rH24sLtCr3xr7VN9aokBxWAcFdaeo4PpMz6XKb X-Received: by 2002:a17:902:d697:: with SMTP id v23-v6mr17252366ply.137.1522852011053; Wed, 04 Apr 2018 07:26:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522852011; cv=none; d=google.com; s=arc-20160816; b=hrX14PS44L8+Nqu3lnYWQntC+S4VHH1lbpI+BscgdQtAe2tjak6wDOQ8kjOqwHn0O1 qmVGjYkUXNinW3aGEtHCgIZxHFRYsYpUpxwHXOvEqT2mvQCjgdCxlC9AucoAh29v4u/D P/VpD4A/UhtaFiGAyrPcu4Y5nI9LrPURlLSSEDFAb/ZKrfU382Iy4T/l6s06u1TVxyPx wE9lZ7lSbhITLRKINqRoEPLsFtyLXDSvmBtJ9R11MqNYCWoz9Y0qCUteiUu7It12qTMk A1/w0sN0EY/xekJBlPSK94wIPAh21ae6lMbrWbEPnLt4KYY3gcd9c5tYtHidXGsMwrd2 toeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dmarc-filter:arc-authentication-results; bh=wsD61GtNomFLC0E9yQgu8OZmOtrBdSxoGP7gPZuuM2s=; b=kgNX9bhNapT6D6Z571qQVzDgfjkxu4ltb7lpE8OfYiaO2oIxM/BGcVN95bn/8KNrHg Tt0HZj8WulNd8rQiqZopxOvcpDr5xXTaxwj2pxRB9vCIM/FP/w4Nmd0vvoZaDlHuhSbx 5+pTLzWzoffRgFlkIABi2XqQ9aC+fzR9dGZhR4Rqd8Q2Zi2dmZdgBKxcCETLfHNfGndz ITOdxNl459lTDe5y+KJdb3unpaaF/yCa/NH9Zv6qrGO5Lziv4kufLwZuwCgnYRwkQBRP RYwEORPk23kjTsiRnyjjbxFs8VtOKiR2HyS92qZ0DzgNo3F5XfdEb2vIIGROyuYD3YxV eF/Q== 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 j15si2332779pfn.389.2018.04.04.07.26.36; Wed, 04 Apr 2018 07:26:51 -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 S1751265AbeDDOZb (ORCPT + 99 others); Wed, 4 Apr 2018 10:25:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:42464 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751117AbeDDOZa (ORCPT ); Wed, 4 Apr 2018 10:25:30 -0400 Received: from gandalf.local.home (cpe-66-24-56-78.stny.res.rr.com [66.24.56.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EE70320838; Wed, 4 Apr 2018 14:25:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EE70320838 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Date: Wed, 4 Apr 2018 10:25:27 -0400 From: Steven Rostedt To: Michal Hocko 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: <20180404102527.763250b4@gandalf.local.home> In-Reply-To: <20180404141052.GH6312@dhcp22.suse.cz> References: <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> <20180404085901.5b54fe32@gandalf.local.home> <20180404141052.GH6312@dhcp22.suse.cz> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. I originally just used NORETRY which would only allocate memory that is currently available and not try to reclaim anything. But people like Joel at Google that required increasing the buffer when memory was mostly taken up by page cache changed it from NORETRY to RETRY_MAYFAIL. But this now causes the issue that a large allocation can take up all memory even when the allocation requested is guaranteed to fail, because there is not enough memory to pull this off. We just want a way to say "hey, is there enough memory in the system to allocate all these pages before we try? We don't need specifics, we just want to make sure we are not allocating way too much". The answer I want is "yes there may be enough (but you may not be able to use it)" or "no, there is definitely not enough for that". Currently si_mem_available() is the closest thing we have to answering that question. I'm fine if the answer is "Yes" even if I can't allocate that memory. 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". -- Steve