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 X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55919C10F25 for ; Sat, 7 Mar 2020 22:38:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0B2552073D for ; Sat, 7 Mar 2020 22:38:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="p8dX6WZJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0B2552073D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 90E0F6B0005; Sat, 7 Mar 2020 17:38:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8BECF6B0006; Sat, 7 Mar 2020 17:38:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D3DF6B0007; Sat, 7 Mar 2020 17:38:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0222.hostedemail.com [216.40.44.222]) by kanga.kvack.org (Postfix) with ESMTP id 631D56B0005 for ; Sat, 7 Mar 2020 17:38:51 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 41BA940D0 for ; Sat, 7 Mar 2020 22:38:51 +0000 (UTC) X-FDA: 76570032462.13.turn79_6a5bfba2ca642 X-HE-Tag: turn79_6a5bfba2ca642 X-Filterd-Recvd-Size: 3783 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Sat, 7 Mar 2020 22:38:50 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 81334206D7; Sat, 7 Mar 2020 22:38:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583620729; bh=jY3ApsFdVBDgkPNklxOZVGDnQe6nZKwAz6e8yhaAOIc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=p8dX6WZJnnsTSKx3Pbeao90AoSS/lmqhhzJb4g/c9rM+9E79l9AWHRczZvXY+nZZC 87Hl9r4MHSXR0zZisAypPokTMfukwXCe/fW1dYYqbL9yHwCB2eCSRcDxdXi3TnRKpx hmJHkcboZInDS20D74tRulzEBmLjkAhoiEeB7aJE= Date: Sat, 7 Mar 2020 14:38:49 -0800 From: Andrew Morton To: Rik van Riel Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, Roman Gushchin , Qian Cai , Vlastimil Babka , Mel Gorman , Anshuman Khandual Subject: Re: [PATCH] mm,page_alloc,cma: conditionally prefer cma pageblocks for movable allocations Message-Id: <20200307143849.a2fcb81a9626dad3ee46471f@linux-foundation.org> In-Reply-To: <20200306150102.3e77354b@imladris.surriel.com> References: <20200306150102.3e77354b@imladris.surriel.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 Fri, 6 Mar 2020 15:01:02 -0500 Rik van Riel wrote: > Posting this one for Roman so I can deal with any upstream feedback and > create a v2 if needed, while scratching my head over the next piece of > this puzzle :) > > ---8<--- > > From: Roman Gushchin > > Currently a cma area is barely used by the page allocator because > it's used only as a fallback from movable, however kswapd tries > hard to make sure that the fallback path isn't used. > > This results in a system evicting memory and pushing data into swap, > while lots of CMA memory is still available. This happens despite the > fact that alloc_contig_range is perfectly capable of moving any movable > allocations out of the way of an allocation. > > To effectively use the cma area let's alter the rules: if the zone > has more free cma pages than the half of total free pages in the zone, > use cma pageblocks first and fallback to movable blocks in the case of > failure. > > Signed-off-by: Rik van Riel > Co-developed-by: Rik van Riel > Signed-off-by: Roman Gushchin fyi, the signoffs are in an unconventional order - usually the primary author comes first. > ... > > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -2711,6 +2711,18 @@ __rmqueue(struct zone *zone, unsigned int order, int migratetype, > { > struct page *page; > > + /* > + * Balance movable allocations between regular and CMA areas by > + * allocating from CMA when over half of the zone's free memory > + * is in the CMA area. > + */ > + if (migratetype == MIGRATE_MOVABLE && > + zone_page_state(zone, NR_FREE_CMA_PAGES) > > + zone_page_state(zone, NR_FREE_PAGES) / 2) { > + page = __rmqueue_cma_fallback(zone, order); > + if (page) > + return page; > + } > retry: > page = __rmqueue_smallest(zone, order, migratetype); > if (unlikely(!page)) { __rmqueue() is a hot path (as much as any per-page operation can be a hot path). What is the impact here?