Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp565804pxu; Thu, 3 Dec 2020 07:22:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJyMx1mBSPsvY/dOrC1OJHc92ME7d715mLE1MZS3CRvjZk+MOUemBCL1uLLiHjCXABzcepGq X-Received: by 2002:aa7:d407:: with SMTP id z7mr3449803edq.234.1607008925912; Thu, 03 Dec 2020 07:22:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607008925; cv=none; d=google.com; s=arc-20160816; b=Z0J7F/K9l8rLElO2oW87hnnU6VPHnP+YZtfmsopwP8TRSatXl+rZqYVkQyEctYCWsI UyNbX4iBmwCxAz2mGOj0gGENXYhGwHxESYaErUiHAd88xD9RzkP0dji7xHEXSQz4pdrz p94BsevLtGMHm0ygJ4I3nzVtv9B655dBHe1uHBAshzT79njqCNhVW0ijdVZE08QUPoe9 bE1tUKtHVQEbEz+WPeMhBSLCxi6G4wFQeep96hwtOgS8Q8pIGAI97QUWYc5nwcfsoxl2 oY24TG01eqS8VsIMHZxCwChb1rqQCn6wa0U9av9WnDmK6LxmrXof5X4/QknyhT5K81jP TWBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=5CZTZvxfaWDdWMFYGm2hND2LpKwDsHuS9rmNu18OIv4=; b=sTdMgkjoaDnn/EcjWwtaT5BftbDRRld21n5ks8frcxb1hc/iHtO1liN9DqwLtNYGWV yBLltxOOdx4or5Y8sPYODmEA46NO8ReBqehliKcb3w2PAGXpAgEy5VW3mnwQShrAW7/6 By+7MlB+FE4B2AkdcoC5N3hnmx5lMGJU7w1iHBfXq07pRO03+jcTScNogXWdAlzrJHvV F6xYJBKB5X78ZmMv5kO+eA0msPW66vjYjknp5NWqNvf1/Wfl+/jm8CKXCZpvpH9LbKxt ZeMshX9h18bK/rzLIHlbGWcvhXZtHhRo8aqA9qqYfaG+AH72FlL/NTNfHBVgb2U7rpAY Ka5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=UtM5hsRa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bo5si1286708ejb.102.2020.12.03.07.21.42; Thu, 03 Dec 2020 07:22:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=UtM5hsRa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730709AbgLCPRF (ORCPT + 99 others); Thu, 3 Dec 2020 10:17:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728022AbgLCPRF (ORCPT ); Thu, 3 Dec 2020 10:17:05 -0500 Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05B9BC061A4E for ; Thu, 3 Dec 2020 07:16:19 -0800 (PST) Received: by mail-ed1-x541.google.com with SMTP id b2so2475923edm.3 for ; Thu, 03 Dec 2020 07:16:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5CZTZvxfaWDdWMFYGm2hND2LpKwDsHuS9rmNu18OIv4=; b=UtM5hsRalnp74tSB5DseBJYzuu6zRCp5gk6C43T8HHM5b7lYUKHv5m+ajdCcBtz4Yk f2EZA76SNOQrDhRAcbtmsgGPb3H9x5UCiS0h0OQGsu+gpvmPmfspIoXCFn3XEckXGHr/ g1o9BllsAicf+nJnyaVXCPJfQ6pEMl2mH6IMuP5ADAoFuU857Q89P5GXGYp4g8j67x8o YpUOpqR4/kpRemrx9hLFBornNXP7VCBeO9pVJ4EgcIliVaO/uoGgb5o25xeB3mL6J8lw qMM4m+R+0ncqtpR62mEGAIks/bzFn5Edlz2K7FIaKtK+pJ5PBFtfO9jeL9y2wHQDkDlG xg1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5CZTZvxfaWDdWMFYGm2hND2LpKwDsHuS9rmNu18OIv4=; b=jck/deiXcxgjVJ14qxf4Vu2AS37onm37f62FZ6svqK6QKE5qVsohApktEawf07huPS Mv+h77iMLs2O2IMIYQ4YJzalRwz+NcDZKqupzgOZjHjUPyGxURFtFIGf2tjv7iu0CXCe jzeZpDWf8AWYx1Pz6mZrIQ6xrRKniHF7BpIDbj0l8OB9MdBPvQ4alxh36ZVTOmCmFOLI 19G2PpJONN6MObmLSiU54D2eN9EIgkOG9+braIJ4CKPNxndGQSR/YRnTvqRLkYn1+4l5 oNV1xDRO5d5xhYjmVVjxKBU1toGtzjq4b8/tZPRLTyN5mVAL+SYFSBHq6DrB/wF3KOn6 lWFQ== X-Gm-Message-State: AOAM532FQe883YZmodWqmP8v1LsrQ98Uk132e3ol81MFrS5HVqwExrXd vYyt/08hkkPTUD3UtMa31bP2/rGD25RAQBc7dbv7Pw== X-Received: by 2002:a50:e00f:: with SMTP id e15mr3443366edl.210.1607008577734; Thu, 03 Dec 2020 07:16:17 -0800 (PST) MIME-Version: 1.0 References: <20201202052330.474592-1-pasha.tatashin@soleen.com> <20201202052330.474592-6-pasha.tatashin@soleen.com> <20201203091703.GA17338@dhcp22.suse.cz> In-Reply-To: <20201203091703.GA17338@dhcp22.suse.cz> From: Pavel Tatashin Date: Thu, 3 Dec 2020 10:15:41 -0500 Message-ID: Subject: Re: [PATCH 5/6] mm: honor PF_MEMALLOC_NOMOVABLE for all allocations To: Michal Hocko Cc: LKML , linux-mm , Andrew Morton , Vlastimil Babka , David Hildenbrand , Oscar Salvador , Dan Williams , Sasha Levin , Tyler Hicks , Joonsoo Kim , mike.kravetz@oracle.com, Steven Rostedt , Ingo Molnar , Jason Gunthorpe , Peter Zijlstra , Mel Gorman , Matthew Wilcox , David Rientjes , John Hubbard Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 3, 2020 at 4:17 AM Michal Hocko wrote: > > On Wed 02-12-20 00:23:29, Pavel Tatashin wrote: > [...] > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > index 611799c72da5..7a6d86d0bc5f 100644 > > --- a/mm/page_alloc.c > > +++ b/mm/page_alloc.c > > @@ -3766,20 +3766,25 @@ alloc_flags_nofragment(struct zone *zone, gfp_t gfp_mask) > > return alloc_flags; > > } > > > > -static inline unsigned int current_alloc_flags(gfp_t gfp_mask, > > - unsigned int alloc_flags) > > +static inline unsigned int cma_alloc_flags(gfp_t gfp_mask, > > + unsigned int alloc_flags) > > { > > #ifdef CONFIG_CMA > > - unsigned int pflags = current->flags; > > - > > - if (!(pflags & PF_MEMALLOC_NOMOVABLE) && > > - gfp_migratetype(gfp_mask) == MIGRATE_MOVABLE) > > + if (gfp_migratetype(gfp_mask) == MIGRATE_MOVABLE) > > alloc_flags |= ALLOC_CMA; > > - > > #endif > > return alloc_flags; > > } > > > > +static inline gfp_t current_gfp_checkmovable(gfp_t gfp_mask) > > +{ > > + unsigned int pflags = current->flags; > > + > > + if ((pflags & PF_MEMALLOC_NOMOVABLE)) > > + return gfp_mask & ~__GFP_MOVABLE; > > + return gfp_mask; > > +} > > + > > It sucks that we have to control both ALLOC and gfp flags. But wouldn't > it be simpler and more straightforward to keep current_alloc_flags as is > (module PF rename) and hook the gfp mask evaluation into current_gfp_context > and move it up before the first allocation attempt? We could do that, but perhaps as a separate patch? I am worried about hidden implication of adding extra scope (GFP_NOIO|GFP_NOFS) to the fast path. Also, current_gfp_context() is used elsewhere, and in some places removing __GFP_MOVABLE from gfp_mask means that we will need to also change other things. For example [1], in try_to_free_pages() we call current_gfp_context(gfp_mask) which can reduce the maximum zone idx, yet we simply set it to: reclaim_idx = gfp_zone(gfp_mask), not to the newly determined gfp_mask. [1] https://soleen.com/source/xref/linux/mm/vmscan.c?r=2da9f630#3239 All scope flags > should be applicable to the hot path as well. It would add few cycles to > there but the question is whether that would be noticeable over just > handling PF_MEMALLOC_NOMOVABLE on its own. The cache line would be > pulled in anyway. Let's try it in a separate patch? I will add it in the next version of this series. Thank you, Pasha