From patchwork Fri Aug 14 17:31:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minchan Kim X-Patchwork-Id: 11715059 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 28610618 for ; Fri, 14 Aug 2020 17:31:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E918220768 for ; Fri, 14 Aug 2020 17:31:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tqi5HlG8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E918220768 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 222C48D0006; Fri, 14 Aug 2020 13:31:47 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 09B078D0003; Fri, 14 Aug 2020 13:31:46 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE1528D0006; Fri, 14 Aug 2020 13:31:46 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0023.hostedemail.com [216.40.44.23]) by kanga.kvack.org (Postfix) with ESMTP id C14F38D0003 for ; Fri, 14 Aug 2020 13:31:46 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 8EF6E4DD0 for ; Fri, 14 Aug 2020 17:31:46 +0000 (UTC) X-FDA: 77149866612.02.camp61_3d1310326ffe Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin02.hostedemail.com (Postfix) with ESMTP id 66C6F100C0CC3 for ; Fri, 14 Aug 2020 17:31:46 +0000 (UTC) X-Spam-Summary: 1,0,0,0c3c5d4a1e7fa5c4,d41d8cd98f00b204,minchan.kim@gmail.com,,RULES_HIT:41:69:355:379:541:800:960:966:973:988:989:1260:1311:1314:1345:1359:1437:1515:1535:1543:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2559:2562:2693:3138:3139:3140:3141:3142:3355:3865:3866:3867:3868:3870:3871:3872:4117:4250:4321:4385:4605:5007:6119:6120:6261:6653:7875:7903:10004:11026:11473:11658:11914:12043:12291:12296:12297:12438:12517:12519:12555:12683:12895:12986:13894:14110:14181:14721:21080:21444:21451:21627:21990:30012:30054,0,RBL:209.85.214.195:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100;04ygo184j1e7mcq63zkqzy6imznazyp3ei6whs7qxk1aa5kn1jh6pdubizrg9bf.57je4nrqjgpoh3fwhsrfd666n548397ttujcx16y8nrt18smbd3kjep8eoi5i95.a-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: camp61_3d1310326ffe X-Filterd-Recvd-Size: 6294 Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Fri, 14 Aug 2020 17:31:45 +0000 (UTC) Received: by mail-pl1-f195.google.com with SMTP id g15so577252plj.6 for ; Fri, 14 Aug 2020 10:31:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=P7rqSrKy/nnoTM8CqDIfpiZXkUt7aO0uWJ6Gz+yM4ps=; b=tqi5HlG8hhVI+w8Ue9/7W4j7xwOkOsdYKdr8TCC8WT8bhI7UWQv6R8wvVzfgXTDCFm zlnuE7QmGQ4U/IT4hkIjkK7KRMLyCyvcL1vtCE2RO/z6mkzHjxCbdlUst5wompRgUaF5 DF2qdF9ksDaG4bvI20ZBSsw8Mp1qocV0TVIi31Is8gZcjkLtP26y0lDcaPCKendWaoxm waO1nVBPQv7klVgJrOffQ1BE89CZqQeCITwZDg0OU0JaTpxObQe06VHEw5m8nYkBZe+y Y2xLf9cBmGx64aaa3MHfEeZLe+nUsd82+Oy7Lro+WHIL1l1r8h68vFT3s54pi4kBwz/g Phpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=P7rqSrKy/nnoTM8CqDIfpiZXkUt7aO0uWJ6Gz+yM4ps=; b=PxR8QRKDQBijSB0P6eaHhNU5+GIYXmFbwiBO1ZAc6MwTW5Xa1+ES6PbhwW2U1+SMV9 Fqrl5rcW2zXcxHy+1SCHDSIbPBwydcWQMY/oxtLGHbMmyx9Yz/Fp6mNZa68rknA6IDX7 SI45nJIfnG/q97VWrEja36VXBlJ6Q+49hEqdSfvOw4A6+pufbT7gb5u3QnvjjRrxmuIh JzcgHUalgAsHIW5biW2m22O/SkGQjIdeP5Fvyz3yDHhUFSMbzsdTq3vNOGV9Na3OtdKp rq+KMdAsm7v6fSt6SrHbZICede6rGtR3J3wgiLRM+ELf4eTn+VroDHNvIfZoLFdbe1yZ 6/pg== X-Gm-Message-State: AOAM533ebSLevivMjOZ5LEDYDS/qUhhbuRr8S2IrDig97KtVuPkjXBCH nYTn/RZRNKkxjYbP/ESBOmTac3Km2qQ= X-Google-Smtp-Source: ABdhPJxOc52ILuwtRtW5VknmfR32RY7TWmdQ/9lQA/hy1dC06Z8JjXec2VabI2CX9fKzLSSTcAcllw== X-Received: by 2002:a17:90a:c201:: with SMTP id e1mr3069280pjt.142.1597426304724; Fri, 14 Aug 2020 10:31:44 -0700 (PDT) Received: from bbox-1.mtv.corp.google.com ([2620:15c:211:1:7220:84ff:fe09:5e58]) by smtp.gmail.com with ESMTPSA id n22sm8522973pjq.25.2020.08.14.10.31.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 10:31:43 -0700 (PDT) From: Minchan Kim To: Andrew Morton Cc: linux-mm , Joonsoo Kim , Vlastimil Babka , John Dias , Suren Baghdasaryan , pullip.cho@samsung.com, Minchan Kim Subject: [RFC 4/7] mm: factor __alloc_contig_range out Date: Fri, 14 Aug 2020 10:31:28 -0700 Message-Id: <20200814173131.2803002-5-minchan@kernel.org> X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog In-Reply-To: <20200814173131.2803002-1-minchan@kernel.org> References: <20200814173131.2803002-1-minchan@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 66C6F100C0CC3 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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: To prepare new API which will reuse most of alloc_contig_range, this patch factor out the common part as __alloc_contig_range. Signed-off-by: Minchan Kim --- mm/page_alloc.c | 50 +++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 4caab47377a7..caf393d8b413 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -8401,28 +8401,7 @@ static int __alloc_contig_migrate_range(struct compact_control *cc, return 0; } -/** - * alloc_contig_range() -- tries to allocate given range of pages - * @start: start PFN to allocate - * @end: one-past-the-last PFN to allocate - * @migratetype: migratetype of the underlaying pageblocks (either - * #MIGRATE_MOVABLE or #MIGRATE_CMA). All pageblocks - * in range must have the same migratetype and it must - * be either of the two. - * @gfp_mask: GFP mask to use during compaction - * - * The PFN range does not have to be pageblock or MAX_ORDER_NR_PAGES - * aligned. The PFN range must belong to a single zone. - * - * The first thing this routine does is attempt to MIGRATE_ISOLATE all - * pageblocks in the range. Once isolated, the pageblocks should not - * be modified by others. - * - * Return: zero on success or negative error code. On success all - * pages which PFN is in [start, end) are allocated for the caller and - * need to be freed with free_contig_range(). - */ -int alloc_contig_range(unsigned long start, unsigned long end, +static int __alloc_contig_range(unsigned long start, unsigned long end, unsigned migratetype, gfp_t gfp_mask) { unsigned long outer_start, outer_end; @@ -8555,6 +8534,33 @@ int alloc_contig_range(unsigned long start, unsigned long end, } EXPORT_SYMBOL(alloc_contig_range); +/** + * alloc_contig_range() -- tries to allocate given range of pages + * @start: start PFN to allocate + * @end: one-past-the-last PFN to allocate + * @migratetype: migratetype of the underlaying pageblocks (either + * #MIGRATE_MOVABLE or #MIGRATE_CMA). All pageblocks + * in range must have the same migratetype and it must + * be either of the two. + * @gfp_mask: GFP mask to use during compaction + * + * The PFN range does not have to be pageblock or MAX_ORDER_NR_PAGES + * aligned. The PFN range must belong to a single zone. + * + * The first thing this routine does is attempt to MIGRATE_ISOLATE all + * pageblocks in the range. Once isolated, the pageblocks should not + * be modified by others. + * + * Return: zero on success or negative error code. On success all + * pages which PFN is in [start, end) are allocated for the caller and + * need to be freed with free_contig_range(). + */ +int alloc_contig_range(unsigned long start, unsigned long end, + unsigned migratetype, gfp_t gfp_mask) +{ + return __alloc_contig_range(start, end, migratetype, gfp_mask); +} + static int __alloc_contig_pages(unsigned long start_pfn, unsigned long nr_pages, gfp_t gfp_mask) {