Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5484293imu; Wed, 26 Dec 2018 03:56:20 -0800 (PST) X-Google-Smtp-Source: ALg8bN65T7ZXOwU1Pq9bfkAEH9d9YHN0DRXGheHe0bqHhrsLzDjJrEODACgelZiHxm76kB026/PH X-Received: by 2002:a17:902:820d:: with SMTP id x13mr20066427pln.229.1545825380120; Wed, 26 Dec 2018 03:56:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545825380; cv=none; d=google.com; s=arc-20160816; b=EylXAH+rKGEdl6w3ZvxPWTi7N5PO/QK6GSCeHI/n98F2jST7JkHDle/vWAqP37sMPm PYsPDNA5fFhX4efORUK8FkqfmviWFXobsWSUoU3CbnnjPRgIHWzpAdJqjv0KSxmMpiS2 qLxrmMGpqBNTGSWCvUnZ6UN2x94IAmh+H/7uB6DNW2Vk16uab/Bw/vXlgNxoiXF5VqTl F+rmYLOFTIUrMoNcKnafcVOyHZXPDMVxq+KkfqZZr10dL0N9HlooBbv73ky9XBPIxsdI lhv3yLHIHBAogxuHehpU4K73ZJ8egfPZm2Pv9Dva4Dp9vQv7IwjQwj6/VkKPnowt0Pvy WReA== 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; bh=9ZNupaXjC2AjfebN6piKpGO4uP+rZWF22pCOM8wxr64=; b=ga/tAWqX6Z8RPCc2Rg1RMnJDUJZeHtsOJcdRlk9PoFuvmA96EvHWwTdS+aAWYmG/nz rgDc1vXg199IIbsg+e5GuRhpl2RKlrWi5jcK3Yd0bxl7NZtaQ8Kwfvw+gPPlrWEwAVWO jex1dkkp92UmA77CAgKLxD8md5da8GNuDkXy7KR7nj4SBx3oTDyj3mmOSiWf2NvHQl// N5S27PrqjvtUBWJ+ty8ZwQYcZ16gVg5axcTEaIUqUYKFm9swhhNYu2Lbo3QxU53k6Wlj YECNGIgIGFYFrhB2q493qpU62me5jazn/YwUCaQIElqxEWP6Z43B1vJwJBLA+30g6JvE bcuw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m7si39236968pfc.118.2018.12.26.03.56.05; Wed, 26 Dec 2018 03:56:20 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726737AbeLZLyF (ORCPT + 99 others); Wed, 26 Dec 2018 06:54:05 -0500 Received: from mx2.suse.de ([195.135.220.15]:34534 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726177AbeLZLyF (ORCPT ); Wed, 26 Dec 2018 06:54:05 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A54BBAC5F; Wed, 26 Dec 2018 11:54:02 +0000 (UTC) Date: Wed, 26 Dec 2018 12:53:55 +0100 From: Michal Hocko To: Konstantin Khorenko Cc: Andrew Morton , Andrey Ryabinin , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Luis Chamberlain , Kees Cook Subject: Re: [PATCH 1/1] mm/page_alloc: add a warning about high order allocations Message-ID: <20181226115355.GJ16738@dhcp22.suse.cz> References: <20181225153927.2873-1-khorenko@virtuozzo.com> <20181225153927.2873-2-khorenko@virtuozzo.com> <20181226084051.GH16738@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181226084051.GH16738@dhcp22.suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 26-12-18 09:40:51, Michal Hocko wrote: > Appart from general comments as a reply to the cover (btw. this all > should be in the changelog because this is the _why_ part of the > justification which should be _always_ part of the changelog). > > On Tue 25-12-18 18:39:27, Konstantin Khorenko wrote: > [...] > > +config WARN_HIGH_ORDER > > + bool "Enable complains about high order memory allocations" > > + depends on !LOCKDEP > > Why? > > > + default n > > + help > > + Enables warnings on high order memory allocations. This allows to > > + determine users of large memory chunks and rework them to decrease > > + allocation latency. Note, some debug options make kernel structures > > + fat. > > + > > +config WARN_HIGH_ORDER_LEVEL > > + int "Define page order level considered as too high" > > + depends on WARN_HIGH_ORDER > > + default 3 > > + help > > + Defines page order starting which the system to complain about. > > + Default is current PAGE_ALLOC_COSTLY_ORDER. > > + > > config HWPOISON_INJECT > > tristate "HWPoison pages injector" > > depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > index e95b5b7c9c3d..258892adb861 100644 > > --- a/mm/page_alloc.c > > +++ b/mm/page_alloc.c > > @@ -4341,6 +4341,30 @@ static inline void finalise_ac(gfp_t gfp_mask, struct alloc_context *ac) > > ac->high_zoneidx, ac->nodemask); > > } > > > > +#ifdef CONFIG_WARN_HIGH_ORDER > > +int warn_order = CONFIG_WARN_HIGH_ORDER_LEVEL; > > + > > +/* > > + * Complain if we allocate a high order page unless there is a __GFP_NOWARN > > + * flag provided. > > + * > > + * Shuts up after 32 complains. > > + */ > > +static __always_inline void warn_high_order(int order, gfp_t gfp_mask) > > +{ > > + static atomic_t warn_count = ATOMIC_INIT(32); > > + > > + if (order >= warn_order && !(gfp_mask & __GFP_NOWARN)) > > + WARN(atomic_dec_if_positive(&warn_count) >= 0, > > + "order %d >= %d, gfp 0x%x\n", > > + order, warn_order, gfp_mask); > > +} > > We do have ratelimit functionality, so why cannot you use it? > > > +#else > > +static __always_inline void warn_high_order(int order, gfp_t gfp_mask) > > +{ > > +} > > +#endif > > + > > /* > > * This is the 'heart' of the zoned buddy allocator. > > */ > > @@ -4361,6 +4385,7 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order, int preferred_nid, > > WARN_ON_ONCE(!(gfp_mask & __GFP_NOWARN)); > > return NULL; > > } > > + warn_high_order(order, gfp_mask); > > > > gfp_mask &= gfp_allowed_mask; > > alloc_mask = gfp_mask; > > Why do you warn about all allocations in the hot path? I thought you > want to catch expensive allocations so I would assume that you would > stick that into a slow path after we are not able to allocate anything > after the first round of compaction. > > Also do you want to warn about opportunistic GFP_NOWAIT allocations that > have a reasonable fallback? And forgot to mention other opportunistic allocations like THP of course. -- Michal Hocko SUSE Labs