Received: by 10.213.65.68 with SMTP id h4csp44895imn; Fri, 30 Mar 2018 13:55:39 -0700 (PDT) X-Google-Smtp-Source: AIpwx495n4Sd9c6tKkKoq8a8hEsrL8541eXaTKqf6Dz5czFMH2eFxXhzIYdsbPbEJ4WJ16nxh7cc X-Received: by 10.98.213.9 with SMTP id d9mr391084pfg.234.1522443339206; Fri, 30 Mar 2018 13:55:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522443339; cv=none; d=google.com; s=arc-20160816; b=imoDTXJHlf6Qu+wUEZ2X/KzfhiqamXhiN+PlCJeKSsDgg8HqqD++GNCI4IRq9F8q73 A6v7gwvcNFg9/8E45MdULbbqvEvt76THsD0iFe8bHnfuf08heQepVCTd77ItxKPfufr8 l3W0BydZYp1yXLrBuvL3OrAh16S6VCkPCzr0pc3nWs3ORLchSUiOh9p3rRfwupgQLaad OHgh4cHnfHn9gPv46gzMKYZpMkxeQyknyxNxO1Am4PmiEhwIaBd6jj3/3A4jZepTzNX0 2bQ4svXarmjq6H4mRAkDrt7a59vNSc2duy+BhRYuBx5SHa2Hqt1te4CXVt1JkYYY4j/J jX1Q== 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:dkim-signature:arc-authentication-results; bh=1Cuw6xoRxc0YAjcf1RJgWujJtWyDBSROH+hw+bcT8MI=; b=ulOLnBz5LP448d8TzCtnYKFo4HT46HuyLkuf3j2S5KEBz+PqhpIDMYJ/oVPiyq3Ohe LJkJOgLZSfnnrGIhOqT/ZBL+kNriUvmlH+VmZ3VjQb1LxMxiUiYXFxtdQG6nFrWaAzUV PNHKM3ryBxUmWj2q/8kgsDvx8mYtvFD06eEJrSFQIapwhS+9vUj4Zkm60rKnpljzRrFo Qvae+IyURK5DmiOv1iHrMBRM2tw5WphxX/vFGj8WMZgFcmPoikayQg3iBbXKfmBno1oT AH2jy6DaYHKUmMBuO11pjkGkyGO7BBJ+ETY0w+eU5zO9augXSFv2W9mI1qA7y0cM+HXq z5pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ditWvOsx; 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 z73si6190670pgd.688.2018.03.30.13.55.22; Fri, 30 Mar 2018 13:55:39 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ditWvOsx; 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 S1752784AbeC3UyE (ORCPT + 99 others); Fri, 30 Mar 2018 16:54:04 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:48416 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752568AbeC3UyC (ORCPT ); Fri, 30 Mar 2018 16:54:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=1Cuw6xoRxc0YAjcf1RJgWujJtWyDBSROH+hw+bcT8MI=; b=ditWvOsxHXHaG02a6CovV45aq VB4C8lZStbVeg8HMpr1zENQT2QK1kkfFryH4tTvNMr5/OuTk2+9i+6Wni962eOwaTv2ybYPdgERax VPy68pSMmBGRn/aefKSuP9JUI/tQyq6/o4calTLRc68MR2qYP/wb1TDtsE86J9nG9nDopLSi1urKP YBBdVN9odOj8twOKSHvC0jkd2njCxW3nDRH6U4c2DM4QFBvmxmdOfE/faHpWWHwwu8oMK/FNOl1Ex DbZCu+IuJqTcz6gPIemHvMnPHqGTN7s6fGTqzaJrebaU+9bfgCTx6PxIc2JUFY3DTTcvD6i4sgJir pPVjVZm7w==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1f2124-0005Jt-9A; Fri, 30 Mar 2018 20:53:56 +0000 Date: Fri, 30 Mar 2018 13:53:56 -0700 From: Matthew Wilcox To: Steven Rostedt Cc: Zhaoyang Huang , Ingo Molnar , linux-kernel@vger.kernel.org, kernel-patch-test@lists.linaro.org, Andrew Morton , Joel Fernandes , Michal Hocko , linux-mm@kvack.org, Vlastimil Babka , Michal Hocko Subject: Re: [PATCH v1] kernel/trace:check the val against the available mem Message-ID: <20180330205356.GA13332@bombadil.infradead.org> References: <1522320104-6573-1-git-send-email-zhaoyang.huang@spreadtrum.com> <20180330102038.2378925b@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180330102038.2378925b@gandalf.local.home> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 30, 2018 at 10:20:38AM -0400, Steven Rostedt wrote: > That said, it appears you are having issues that were caused by the > change by commit 848618857d2 ("tracing/ring_buffer: Try harder to > allocate"), where we replaced NORETRY with RETRY_MAYFAIL. The point of > NORETRY was to keep allocations of the tracing ring-buffer from causing > OOMs. But the RETRY was too strong in that case, because there were > those that wanted to allocate large ring buffers but it would fail due > to memory being used that could be reclaimed. Supposedly, RETRY_MAYFAIL > is to allocate with reclaim but still allow to fail, and isn't suppose > to trigger an OOM. From my own tests, this is obviously not the case. That's not exactly what the comment says in gfp.h: * __GFP_RETRY_MAYFAIL: The VM implementation will retry memory reclaim * procedures that have previously failed if there is some indication * that progress has been made else where. It can wait for other * tasks to attempt high level approaches to freeing memory such as * compaction (which removes fragmentation) and page-out. * There is still a definite limit to the number of retries, but it is * a larger limit than with __GFP_NORETRY. * Allocations with this flag may fail, but only when there is * genuinely little unused memory. While these allocations do not * directly trigger the OOM killer, their failure indicates that * the system is likely to need to use the OOM killer soon. The * caller must handle failure, but can reasonably do so by failing * a higher-level request, or completing it only in a much less * efficient manner. * If the allocation does fail, and the caller is in a position to * free some non-essential memory, doing so could benefit the system * as a whole. It seems to me that what you're asking for at the moment is lower-likelihood-of-failure-than-GFP_KERNEL, and it's not entirely clear to me why your allocation is so much more important than other allocations in the kernel. Also, the pattern you have is very close to that of vmalloc. You're allocating one page at a time to satisfy a multi-page request. In lieu of actually thinking about what you should do, I might recommend using the same GFP flags as vmalloc() which works out to GFP_KERNEL | __GFP_NOWARN (possibly | __GFP_HIGHMEM if you can tolerate having to kmap the pages when accessed from within the kernel).