Received: by 10.213.65.68 with SMTP id h4csp266428imn; Fri, 30 Mar 2018 20:11:51 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/wiNQk2WgynDm3ki68t5bWVnM/u+xqqXmvemEuLTDcPzomAic0vW3NAMwBI+dbvRlc7aiI X-Received: by 2002:a17:902:a981:: with SMTP id bh1-v6mr1502074plb.255.1522465911083; Fri, 30 Mar 2018 20:11:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522465911; cv=none; d=google.com; s=arc-20160816; b=eBKDDAtOfuGLVLr6lwN2RFVgMuhIG8UL986TvLigfY/Q+SWS+gvr0sSHTNKc1ueQ07 +AhUBVbSQhFBBXFPUDO7hXKWhchnvoATxudPfV1nKIrA3zEAM4BsM39OVB2eTIkpcDNK Bvr1tSLL2M+4JJyMXsgqV/XGulmfjO8ab15RuRsnHg2vpTmKAMhoR62ZC24gya29xjce /pf3KuifmaJYnrsCUosLbo5VYItoiQ5uJxaR/D8nUSQBMaEFQPUtm2dI0e7TPBSb1naj Rssq03loIfy4+XjgJZGDiLlfqTM0HwQf0kuwIzSGNRaxuBWWRbqHTE+8XF+zlC7Ns7h5 KQEA== 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=w6Srt0mMvbOlBbrD7QZ8+XQMYxXeZPVpLGQ5OqPntRA=; b=IQzUD66eDEslSaAKBtwHEak+K2GQpcMUq6NugY6FzeJVSPH3RVRMo31pyHKF1NeSdO q1QIV4yFWcVfjiZ+HnJ3slBVYM2NfTV/KOFK1Z3VRCGqZAxXjdTY9lRsKbaV9smjhJqj +Pr7VaBweNyrNz/es+xFHtVKKRrD1OBZrzc1D56NlbYPetLP3KtX99SOJ5xw+AiLsg8+ S+VFBL+AxreMe4MUPhc40QQDs0OHKmXr8Lf2JOgBtE6iqbAg7aIUy+WAS6l/e+74nSnS SxKeDRl/FJKtN/i7fVB4il/sxVp55qm2ov/QijfK9QS7hgrrl5o3AzsnDHPsm2vSelIR Tq1w== 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 31-v6si7185629plz.467.2018.03.30.20.11.01; Fri, 30 Mar 2018 20:11: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 S1752839AbeCaDHi (ORCPT + 99 others); Fri, 30 Mar 2018 23:07:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:32788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752819AbeCaDHh (ORCPT ); Fri, 30 Mar 2018 23:07:37 -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 A874021770; Sat, 31 Mar 2018 03:07:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A874021770 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: Fri, 30 Mar 2018 23:07:33 -0400 From: Steven Rostedt To: Matthew Wilcox Cc: Joel Fernandes , Zhaoyang Huang , Ingo Molnar , LKML , kernel-patch-test@lists.linaro.org, Andrew Morton , Michal Hocko , "open list:MEMORY MANAGEMENT" , Vlastimil Babka , Michal Hocko Subject: Re: [PATCH v1] kernel/trace:check the val against the available mem Message-ID: <20180330230733.2bf010f2@gandalf.local.home> In-Reply-To: <20180331021857.GD13332@bombadil.infradead.org> References: <1522320104-6573-1-git-send-email-zhaoyang.huang@spreadtrum.com> <20180330102038.2378925b@gandalf.local.home> <20180330205356.GA13332@bombadil.infradead.org> <20180330173031.257a491a@gandalf.local.home> <20180330174209.4cb77003@gandalf.local.home> <20180330214151.415e90ea@gandalf.local.home> <20180331021857.GD13332@bombadil.infradead.org> 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 Fri, 30 Mar 2018 19:18:57 -0700 Matthew Wilcox wrote: > Again though, this is the same pattern as vmalloc. There are any number > of places where userspace can cause an arbitrarily large vmalloc to be > attempted (grep for kvmalloc_array for a list of promising candidates). > I'm pretty sure that just changing your GFP flags to GFP_KERNEL | > __GFP_NOWARN will give you the exact behaviour that you want with no > need to grub around in the VM to find out if your huge allocation is > likely to succeed. Not sure how this helps. Note, I don't care about consecutive pages, so this is not an array. It's a link list of thousands of pages. How do you suggest allocating them? The ring buffer is a link list of pages. What I currently do is to see how many more pages I need. Allocate them one at a time and put them in a temporary list, if it succeeds I add them to the ring buffer, if not, I free the entire list (it's an all or nothing operation). The allocation I'm making doesn't warn. The problem is the GFP_RETRY_MAYFAIL, which will try to allocate any possible memory in the system. When it succeeds, the ring buffer allocation logic will then try to allocate another page. If we add too many pages, we will allocate all possible pages and then try to allocate more. This allocation will fail without causing an OOM. That's not the problem. The problem is if the system is active during this time, and something else tries to do any allocation, after all memory has been consumed, that allocation will fail. Then it will trigger an OOM. I showed this in my Call Trace, that the allocation that failed during my test was something completely unrelated, and that failure caused an OOM. What this last patch does is see if there's space available before it even starts the process. Maybe I'm missing something, but I don't see how NOWARN can help. My allocations are not what is giving the warning. -- Steve