From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D536AC5479D for ; Wed, 11 Jan 2023 15:37:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 489C28E0003; Wed, 11 Jan 2023 10:37:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 412C88E0001; Wed, 11 Jan 2023 10:37:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2B3968E0003; Wed, 11 Jan 2023 10:37:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 1BAA98E0001 for ; Wed, 11 Jan 2023 10:37:37 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id ED9E312031B for ; Wed, 11 Jan 2023 15:37:36 +0000 (UTC) X-FDA: 80342922912.19.A031869 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf20.hostedemail.com (Postfix) with ESMTP id 3C8431C001B for ; Wed, 11 Jan 2023 15:37:34 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=ANOeU6im; spf=pass (imf20.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673451455; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=H5PrZhGxAXPih4jW/nQocRH5mJY9ZxQOPuFJC4UKqxc=; b=F0G3ARclVWauXY/eWrtHqf9Ds3dX8vH9KVborJ3VQ/tk8JnxJym80JV0/vcgs5CRwQHCyQ plJU1pU1sFLo6kwACOj/PztJRIEuNb9POJOxGExFtDKlQ3UbW/EjivAGvIZr9/grxTpeJ6 rSwZwAndXwoFdcqKUsdmBRRyUgYLpl8= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=ANOeU6im; spf=pass (imf20.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673451455; a=rsa-sha256; cv=none; b=M7zQmFAgCrRBxXaw8zI/zqRlgDxm5A9ez4CPmIP8AdnHxhnaWX6a80MzpnKC8cu36RYfhV ESoKhor7JDB3MNx7xXwma5K/fdMyTQJRwzUijBVhXdRSprZjReddUg9/VXj3kS6ONXDDfz A3Tqf2FY23DKcWjY2U1deyB5Gc+1EhU= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id AAE3A8B896; Wed, 11 Jan 2023 15:37:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1673451453; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=H5PrZhGxAXPih4jW/nQocRH5mJY9ZxQOPuFJC4UKqxc=; b=ANOeU6imNYB3YhDQhQexlYgh0cL0lzk3Nt32U9yhMFbLO42nW6eeTkOWED21iFXAgb/SVp TK2apZMAjfWHNRtFCzX2s3xRfaZFQK11gncGb5+MDWyQLpvBoBruZ+n8NKqxqNAybU+m6V /Ykdr6nnso/PjaSV9/uABIpvWi1Q/Nk= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8EDD61358A; Wed, 11 Jan 2023 15:37:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id HgAAIL3XvmM6OAAAMHmgww (envelope-from ); Wed, 11 Jan 2023 15:37:33 +0000 Date: Wed, 11 Jan 2023 16:37:32 +0100 From: Michal Hocko To: Mel Gorman Cc: Linux-MM , Andrew Morton , NeilBrown , Thierry Reding , Matthew Wilcox , Vlastimil Babka , LKML Subject: Re: [PATCH 4/7] mm/page_alloc: Explicitly define what alloc flags deplete min reserves Message-ID: References: <20230109151631.24923-1-mgorman@techsingularity.net> <20230109151631.24923-5-mgorman@techsingularity.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230109151631.24923-5-mgorman@techsingularity.net> X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 3C8431C001B X-Rspam-User: X-Stat-Signature: kzcnybutipmi65i3nwudw81kcwtdmfcd X-HE-Tag: 1673451454-902975 X-HE-Meta: U2FsdGVkX1/04+AzgTmYVA122Ig4goXTfNFuKSGgHLOtznOiH/O+Lsx9sL+aDrKP8+Vv4wS710iMhVna4t41znPguZEvGjQfh2AGRJb5Npx03aal1u/0N9AyWc2GhJVwu3cQFvjnJ8Z+UDIwvK7+B8Z2GEni7l5CnYZ2q2s+4rGoEe92tQJKxH4E7dht+PBYUFEC9sv3jPB3z8mo70Hpz8PC8HhXJPHE1CrwI43RFle0Y+v5uIqEI1YajV85QxwAt0Bop0Oo/1QSyps1etr6alTTXFIv1OZks8PKPPnttrSbYAvzx6by040b+Zg/M8vSPL0RQTjiGWpXO9Z7DJQVCQuTM/O2cQl6vaPD8L41V6xJsulFCd+GhrFlkI0W0+Tzdp3RHVCh+HbLLru/x7NhBJSheSVsEtgJ822u1ZX00uEGFLn5bNl5pEXjhRmEdn6TvFe5k7fT61eIpuap+ICMHAlj4KFW+2y8IOUjSo2tw7AQ8e5Yi2DaOmgZlh9KlsMqY0Hr2y9GXbedn7+By2wk226mduDMb3udQcDCwme7mDs0WLlDcVJkqwICBT5WFf7jr7/0BnWiqRn+XWQvp79yOr3uRGhyqtNmXg21thfakSkN/yiUnr7HbMsvjI5DTdqZ6e3QSeN2p3v9rGPJ/qKn/7cL0BsstxEnsl0r//RN5724q+lwC88Vvfkgkiy25ZP+N11ykohmoqcUOUxnyoPZ8PUQE/EplCJqqxg2QFcYv5qERrM4jMBCc0hRvUPdg/0RjfjaGOUC0A3eGkXgc6/MMq4M4B31rpWbIyOIDfMUOqo8t4sgpyOBLLgA/hhZMrZ6PUrc+RhMyWlAoYa9kuG7wQjo1jZEJmey0tg51m9qS9WDf9YdBpPzh3X8UV/jD6sgSIwUh36FRPrzeTp3Xt48y9yaqPxsh03qO+kop9nI2JbYMYxYO0TalTvgVIqcS0saw4p3HZpPmbKQ0ydVpSC KYm8SejV 7nU64Ti4QqQvGAj8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon 09-01-23 15:16:28, Mel Gorman wrote: > As there are more ALLOC_ flags that affect reserves, define what flags > affect reserves and clarify the effect of each flag. I like this! It makes the code much easier to follow. > Signed-off-by: Mel Gorman Acked-by: Michal Hocko Thanks! > --- > mm/internal.h | 3 +++ > mm/page_alloc.c | 34 ++++++++++++++++++++++------------ > 2 files changed, 25 insertions(+), 12 deletions(-) > > diff --git a/mm/internal.h b/mm/internal.h > index 178484d9fd94..8706d46863df 100644 > --- a/mm/internal.h > +++ b/mm/internal.h > @@ -749,6 +749,9 @@ unsigned int reclaim_clean_pages_from_list(struct zone *zone, > #define ALLOC_HIGHATOMIC 0x200 /* Allows access to MIGRATE_HIGHATOMIC */ > #define ALLOC_KSWAPD 0x800 /* allow waking of kswapd, __GFP_KSWAPD_RECLAIM set */ > > +/* Flags that allow allocations below the min watermark. */ > +#define ALLOC_RESERVES (ALLOC_HARDER|ALLOC_MIN_RESERVE|ALLOC_HIGHATOMIC|ALLOC_OOM) > + > enum ttu_flags; > struct tlbflush_unmap_batch; > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 0ef4f3236a5a..6f41b84a97ac 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -3949,15 +3949,14 @@ ALLOW_ERROR_INJECTION(should_fail_alloc_page, TRUE); > static inline long __zone_watermark_unusable_free(struct zone *z, > unsigned int order, unsigned int alloc_flags) > { > - const bool alloc_harder = (alloc_flags & (ALLOC_HARDER|ALLOC_OOM)); > long unusable_free = (1 << order) - 1; > > /* > - * If the caller does not have rights to ALLOC_HARDER then subtract > - * the high-atomic reserves. This will over-estimate the size of the > - * atomic reserve but it avoids a search. > + * If the caller does not have rights to reserves below the min > + * watermark then subtract the high-atomic reserves. This will > + * over-estimate the size of the atomic reserve but it avoids a search. > */ > - if (likely(!alloc_harder)) > + if (likely(!(alloc_flags & ALLOC_RESERVES))) > unusable_free += z->nr_reserved_highatomic; > > #ifdef CONFIG_CMA > @@ -3981,25 +3980,36 @@ bool __zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark, > { > long min = mark; > int o; > - const bool alloc_harder = (alloc_flags & (ALLOC_HARDER|ALLOC_OOM)); > > /* free_pages may go negative - that's OK */ > free_pages -= __zone_watermark_unusable_free(z, order, alloc_flags); > > - if (alloc_flags & ALLOC_MIN_RESERVE) > - min -= min / 2; > + if (unlikely(alloc_flags & ALLOC_RESERVES)) { > + /* > + * __GFP_HIGH allows access to 50% of the min reserve as well > + * as OOM. > + */ > + if (alloc_flags & ALLOC_MIN_RESERVE) > + min -= min / 2; > > - if (unlikely(alloc_harder)) { > /* > - * OOM victims can try even harder than normal ALLOC_HARDER > + * Non-blocking allocations can access some of the reserve > + * with more access if also __GFP_HIGH. The reasoning is that > + * a non-blocking caller may incur a more severe penalty > + * if it cannot get memory quickly, particularly if it's > + * also __GFP_HIGH. > + */ > + if (alloc_flags & ALLOC_HARDER) > + min -= min / 4; > + > + /* > + * OOM victims can try even harder than the normal reserve > * users on the grounds that it's definitely going to be in > * the exit path shortly and free memory. Any allocation it > * makes during the free path will be small and short-lived. > */ > if (alloc_flags & ALLOC_OOM) > min -= min / 2; > - else > - min -= min / 4; > } > > /* > -- > 2.35.3 -- Michal Hocko SUSE Labs