Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp339174pxu; Thu, 3 Dec 2020 01:19:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJyETjK7p1deiLWwynjh4WM1j+tV3P4v7lfihstZaZ28jolJx0Btp/fbzPbT2JTIaCGuBKm9 X-Received: by 2002:a17:906:e81:: with SMTP id p1mr1680363ejf.494.1606987178331; Thu, 03 Dec 2020 01:19:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606987178; cv=none; d=google.com; s=arc-20160816; b=AnQxhIZ17LcTdjpvEmjRq9jbTrvaoRZwg6UBW+z3mQqVED7FBwoEvrk/gtlpycyPHd lHDR8n5YKhI3eANZfQv6jtvem2UvM6MqxMketADzB6GGRaNFBZYrNg4XXvR2X7dbo93o XtRp6FTCc/4kHm1auGxZgPFZZ4BM43ewEF86pEbiZzeQrHf31eGs3xHnl/v1QPqdprBa BIfE8xq/SRY6eQanHhZlI4lCGAi/tcUyM2VST7ade3KqnDzHxOUPxc7VuX/o7YKeE8Z6 uerXbfePQQnbEWbKUnKRSXzV7YyBrUg2FnC8AmU3+kQesNUuEdaJxG/bpHg4Op0te+bl sVaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=pJo8+wKiZ3+Hg8cb6ALfgT2xkFoyxjLsrCfxit8Yp2E=; b=HMAZ7JBgjT6dFcEiB4MNhqNTqgUIjpy/OllgcHz0xfCm7dEDaSZcJEQhceWceMzwFm t+YrAnrK+hwxjLbFQxzyK4V1dEuXxuL99CyYIGK6uANuqa6Cxwa+ExAyTbu+NM9AK0Mo +vOEML2FaEo2FAib95mrBt8PQrOtOEBI+uYAfvarA81Aw7+b4K7z3tohMoAP5Phuvy/y 6EEW14HGV467lCHF7fPsbZ+xf1UoLSf+gLPXma11G1GzjfJUfoINDjBChx45THQwxLSv PyJhwpW+FFcyIuuMs5RH3U78ISZrJy0uH+jtwTD2M9gup0zG0T/kk+4qIKk+onP80Sgb 6xWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=alp2N0FF; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ch15si807681ejb.674.2020.12.03.01.19.15; Thu, 03 Dec 2020 01:19:38 -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=@suse.com header.s=susede1 header.b=alp2N0FF; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387551AbgLCJRw (ORCPT + 99 others); Thu, 3 Dec 2020 04:17:52 -0500 Received: from mx2.suse.de ([195.135.220.15]:56360 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726003AbgLCJRv (ORCPT ); Thu, 3 Dec 2020 04:17:51 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1606987025; 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=pJo8+wKiZ3+Hg8cb6ALfgT2xkFoyxjLsrCfxit8Yp2E=; b=alp2N0FFF1Bw/AuR9hA68gWaE2No/3WseM0Njj+UjmgU98vy84/JmCpG/+zCbkBEGj8s4Q QAiKK8M8RbOrxPyLMJ9/JgkjDZBavCCWmqDdAO2JkkvFOuFmKFPVdvjyXn51YVRnUfXkMW ZvUvdj9sG2hcLBMEf5bH5OB9d9hv/Y4= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 08BC7AC55; Thu, 3 Dec 2020 09:17:05 +0000 (UTC) Date: Thu, 3 Dec 2020 10:17:03 +0100 From: Michal Hocko To: Pavel Tatashin Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, vbabka@suse.cz, david@redhat.com, osalvador@suse.de, dan.j.williams@intel.com, sashal@kernel.org, tyhicks@linux.microsoft.com, iamjoonsoo.kim@lge.com, mike.kravetz@oracle.com, rostedt@goodmis.org, mingo@redhat.com, jgg@ziepe.ca, peterz@infradead.org, mgorman@suse.de, willy@infradead.org, rientjes@google.com, jhubbard@nvidia.com Subject: Re: [PATCH 5/6] mm: honor PF_MEMALLOC_NOMOVABLE for all allocations Message-ID: <20201203091703.GA17338@dhcp22.suse.cz> References: <20201202052330.474592-1-pasha.tatashin@soleen.com> <20201202052330.474592-6-pasha.tatashin@soleen.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201202052330.474592-6-pasha.tatashin@soleen.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? 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. -- Michal Hocko SUSE Labs