From patchwork Fri Aug 14 17:31:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minchan Kim X-Patchwork-Id: 11715049 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 31A4C618 for ; Fri, 14 Aug 2020 17:31:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F2AC220829 for ; Fri, 14 Aug 2020 17:31:45 +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="PAeUj220" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F2AC220829 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 D19BC6B000A; Fri, 14 Aug 2020 13:31:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CA3388D0002; Fri, 14 Aug 2020 13:31:44 -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 B438C6B0098; Fri, 14 Aug 2020 13:31:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 99DB46B000A for ; Fri, 14 Aug 2020 13:31:44 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 3425A180AD815 for ; Fri, 14 Aug 2020 17:31:44 +0000 (UTC) X-FDA: 77149866528.24.team61_301196b26ffe Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin24.hostedemail.com (Postfix) with ESMTP id DDA211A4AE for ; Fri, 14 Aug 2020 17:31:42 +0000 (UTC) X-Spam-Summary: 1,0,0,88bea24aa2d7d2d6,d41d8cd98f00b204,minchan.kim@gmail.com,,RULES_HIT:41:355:379:541:560:800:960:966:973:988:989:1260:1311:1314:1345:1359:1437:1515:1535:1542:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2559:2562:2731:3138:3139:3140:3141:3142:3354:3866:3867:3868:3870:3872:4321:4385:5007:6120:6261:6653:7904:8957:9010:9592:10004:11026:11232:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12895:12986:13894:14181:14721:21080:21444:21451:21627:30054:30070,0,RBL:209.85.215.195:@gmail.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100;04y8m4tkf7qprsihem1z19e4auwjhyptbjbqfo1kx136ygwpf3ny4rbuzcaq7qk.i6upwixdzrabp85s89akfgub7gpuohi84ucpew1t15461jjw34tngsz3k143a1i.r-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:24,LUA_SUMMARY:none X-HE-Tag: team61_301196b26ffe X-Filterd-Recvd-Size: 5874 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by imf06.hostedemail.com (Postfix) with ESMTP for ; Fri, 14 Aug 2020 17:31:42 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id 189so4213372pgg.13 for ; Fri, 14 Aug 2020 10:31:42 -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=UAAMpOsV4LSeCHvFCmQVj34sFgyBlHyc8J4tU9vV214=; b=PAeUj220oSbCQOaXQgGjTYHUwu92+h+iiMSngwIIwEJ4HZuJrr2rQ+CHSlxKQ3Z+EA Lk74altv5AYeQ9L2/OSO5Q+Vj95grWKo8WtUlbcW/1lzy/DNTGx6C9YO4Tv38Mq+Vg23 u36UPmFp9x+Eav3zhsDcwGU963Hc36EjxZoZ4rNgGusn7mHc0uNaklCeS/oInh9UI3lg ZHeo0FIJFc8L8nw7WZbchEs5cgcC7x/mjVQM8FP6VwPolD7S0NxwH2CKQjMf6tr1SwPs JM/fdd5D9O3sWmfkWCG+zK3ON8BWpN8+qxdoPYBCPe5PwF91JfAzzW39y9EkJWdMvae4 q/uA== 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=UAAMpOsV4LSeCHvFCmQVj34sFgyBlHyc8J4tU9vV214=; b=rog4lZF3FeCePnEjTknXn0uPBFmcEk6+k+d31tjIBvXCqO8NHl1JbIbkmqzez/UeNR 3aTES7y6dtMUB1EHcUtP+F+mGeZmAkrKxiH7xaGdbpfGpjN+Cox+Z4AbsmQu5zXEtEVJ ZNaqoZ73OVRwzyO8GOx9tDEu+eRq2yo7Na9gI+Z8NC16a7tfUbUveA0F0S24WkgM0NDo LMlwNkQG6RB1W7BqXnUzUIg+omXD4Hngh5Or91xAaQSs+nA2yoRVC38aJu/mtUcOrm/J yeJSuhugMJxGL96Zkw8oS7JTiMtGJ8OjTCmu6tkLUTUOaJ0uI8VnM22iZVUdAeLPYLnf hXBQ== X-Gm-Message-State: AOAM533Q5P5H8YTvAV8nfVUDNDHSCozgGkSP8z7npGN/zKu7TrXfyg6V wlMu/pjptT6BMu+Bc8+zw3w= X-Google-Smtp-Source: ABdhPJz994pPoGzHYt6CFnPTK3o6kSa5K3u66Dghha8kvJX+ZYKcf4Otmg12gR6iI1iElT2liX0usg== X-Received: by 2002:a63:f752:: with SMTP id f18mr2316540pgk.94.1597426301319; Fri, 14 Aug 2020 10:31:41 -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.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 10:31:40 -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 2/7] mm: introduce split_page_by_order Date: Fri, 14 Aug 2020 10:31:26 -0700 Message-Id: <20200814173131.2803002-3-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: DDA211A4AE X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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: This patch introduces split_page_by_order to support splitting a high-order page into group of smaller high-order pages and use it in split_map_pages for supporting upcoming high-order bulk operation. This patch shouldn't change any behavior. Signed-off-by: Minchan Kim --- include/linux/mm.h | 2 ++ mm/compaction.c | 2 +- mm/page_alloc.c | 27 +++++++++++++++++++-------- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 8ab941cf73f4..9a51abbe8625 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -849,6 +849,8 @@ void __put_page(struct page *page); void put_pages_list(struct list_head *pages); +void split_page_by_order(struct page *page, unsigned int order, + unsigned int new_order); void split_page(struct page *page, unsigned int order); /* diff --git a/mm/compaction.c b/mm/compaction.c index 176dcded298e..f31799a841f2 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -98,7 +98,7 @@ static void split_map_pages(struct list_head *list) post_alloc_hook(page, order, __GFP_MOVABLE); if (order) - split_page(page, order); + split_page_by_order(page, order, 0); for (i = 0; i < nr_pages; i++) { list_add(&page->lru, &tmp_list); diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 8ce30cc50577..4caab47377a7 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3188,6 +3188,24 @@ void free_unref_page_list(struct list_head *list) local_irq_restore(flags); } +/* + * split_page_by_order takes a non-compound higher-order page, and splits + * it into n (1 << (order - new_order)) sub-order pages: page[0..n] + * Each sub-page must be freed individually. + */ +void split_page_by_order(struct page *page, unsigned int order, + unsigned int new_order) +{ + int i; + + VM_BUG_ON_PAGE(PageCompound(page), page); + VM_BUG_ON_PAGE(!page_count(page), page); + + for (i = 1; i < (1 << (order - new_order)); i++) + set_page_refcounted(page + i * (1 << new_order)); + split_page_owner(page, order, new_order); +} + /* * split_page takes a non-compound higher-order page, and splits it into * n (1<