Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp82883rdd; Mon, 8 Jan 2024 18:59:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IEO38TWxZWN7SbrNFNQHux94rYvazr6FEFWApYBb0TGa9W6vtoah0jOI0FtwolM9/ArmW3m X-Received: by 2002:a0c:f891:0:b0:681:16ee:2cf6 with SMTP id u17-20020a0cf891000000b0068116ee2cf6mr124283qvn.12.1704769193893; Mon, 08 Jan 2024 18:59:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704769193; cv=none; d=google.com; s=arc-20160816; b=JJIobQ5tqBhZqz8GO+nlib7RWqUvxIek1Fv6gsKQQQ3k/YFB/bDZyLi+yp+sG9JSvD G7fkC5X9eSQaSd0yHQyf+iCNUePd+CJU92GERCZRlEmEv+GGQNS175+8Ihk4t4JPv9TI wN133W7WJme9+jGREj7nNOxsfaKUnG/uIj6UxGf1+O3B3SyajahBM0uoyqOKfrBLFcuM +KAHKgY9TzLtKEvCOVEJlomVIOWVbdb5pXvEbgnJXztoRvUjnvJTe6MeWlLTRjdbF3EC 1wQA53M6hep3JwFNRRF7jwHGd6u37KP/P5OcOPk97w8PkmhusVUxylZYn9FgafQ0pO+R 0frQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:dkim-signature:date; bh=az2DbloPvptLGPocf4LwwB3VnB6zIJOBfZxKs8IGge4=; fh=bLhTTycSMaEbYmmpqbJfGo9ql5eLh/oSiidtYSQ2vkU=; b=lNvNpn6j6/wjtlQA3UNr69JUitddRvJNWhh7rCscgY+QFUYfs6LQFln7OmpIeyh0RD bHvhuA8LfObtokEZYYSNkKPTOwsXr8xlkI1sa7OH9/G2qldOAZF7U9rkFkFm2qdhNkjO OR3enLolRCpL9YEoUT4114VVPwnvcgZRGgmEOmSTvTkiMbo1SknH/qc6+RSgjV0mgtPb V6azJOivqE5fuHH3NgbJ96tZVcITf1eUqNne7+RE6jMocm+SwLwnFdtOcghBakIWDvGa EqMED/m+jQuK6AaFbLbuj9LokEoRyckkKTUoutD3veXo9rwwnQpcZ9nu4xOfzapB6Nmd LU2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=asguh6I+; spf=pass (google.com: domain of linux-kernel+bounces-20313-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20313-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id a14-20020a0ce38e000000b0067ef59c437csi1359474qvl.543.2024.01.08.18.59.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 18:59:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-20313-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=asguh6I+; spf=pass (google.com: domain of linux-kernel+bounces-20313-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20313-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 5B8F61C2344A for ; Tue, 9 Jan 2024 02:59:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EE7845686; Tue, 9 Jan 2024 02:59:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="asguh6I+" Received: from out-176.mta0.migadu.com (out-176.mta0.migadu.com [91.218.175.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 11291539F for ; Tue, 9 Jan 2024 02:59:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Date: Mon, 8 Jan 2024 18:59:27 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1704769173; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=az2DbloPvptLGPocf4LwwB3VnB6zIJOBfZxKs8IGge4=; b=asguh6I+FXzW5501V/WBdY7tt240i1gZsdScbLKwUFArc0vqJ0JccSkhU18TwzFFsAH5FG eSqZA4hgx20YzUqTBRVoKWJ6ACi/LMgAy2mV5GxGIXdiNCmwe6ArM6oUIFsfLScV2gyKET GEya9crCs5+sOySE1K5jxrgYrp7woIg= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Sukadev Bhattiprolu Cc: Minchan Kim , Chris Goldsworthy , Andrew Morton , Rik van Riel , Roman Gushchin , Vlastimil Babka , Joonsoo Kim , Georgi Djakov , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm,page_alloc,cma: configurable CMA utilization Message-ID: References: <20230131071052.GB19285@hu-sbhattip-lv.qualcomm.com> <20230131201001.GA8585@hu-sbhattip-lv.qualcomm.com> <20230201040628.GA3767@hu-cgoldswo-sd.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Migadu-Flow: FLOW_OUT On Mon, Jan 08, 2024 at 12:15:05PM -0800, Sukadev Bhattiprolu wrote: > > On 1/5/2024 4:05 PM, Roman Gushchin wrote: > > I'm not sure there is a "one size fits all" solution here. > agree - that's why we are thinking a configurable cma utilization would be > useful. > > There are two distinctive cases: > > 1) A relatively small cma area used for a specific purpose. This is how cma > > was used until recently. And it was barely used by the kernel for non-cma > > allocations. > > 2) A relatively large cma area which is used to allocate gigantic hugepages > > and as an anti-fragmentation mechanism in general (basically as a movable > > zone). In this case it might be preferable to use cma for movable > > allocations, because the space for non-movable allocations might be limited. > > > > I see two options here: > > 1) introduce per-cma area flags which will define the usage policy > Could you please elaborate on this - how would we use the per-cma flags > when allocating pages? I mean potentially we can add some per-cma area configuration options which will define the "priority" of using the memory from this cma area. > > 2) redesign the page allocator to better take care of fragmentation at 1Gb scale > > > > The latter is obviously not a small endeavour. > > The fundamentally missing piece is a notion of an anti-fragmentation cost. > > E.g. how much work does it makes sense to put into page migration > > before "polluting" a new large block of memory with an unmovable folio. > > Stepping back, we are trying to solve for a situation where system: > ??????? - has lot of movable allocs in zone normal > ??????? - has lot of idle memory in CMA region > ??????? - but is low on memory for unmovable allocs, leading to oom-kills > > On devices where cma region is mostly idle, allocating movable pages from > the cma region would have lesser overhead? It's not that easy: imagine booting up a small system with a cma area reserved for some hardware-related operations. This is pretty much what cma was initially designed. How to not fill the cma area up with the page cache? Thanks!