From patchwork Wed Jul 14 19:35:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 12377781 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham 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 8EDEAC1B08C for ; Wed, 14 Jul 2021 19:36:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3B750613CB for ; Wed, 14 Jul 2021 19:36:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3B750613CB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 30BC36B0088; Wed, 14 Jul 2021 15:36:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2BEF86B008C; Wed, 14 Jul 2021 15:36:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 072046B0092; Wed, 14 Jul 2021 15:36:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0149.hostedemail.com [216.40.44.149]) by kanga.kvack.org (Postfix) with ESMTP id CB3B46B0088 for ; Wed, 14 Jul 2021 15:36:23 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id B5798181D3979 for ; Wed, 14 Jul 2021 19:36:22 +0000 (UTC) X-FDA: 78362199804.24.A2CA697 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf20.hostedemail.com (Postfix) with ESMTP id 2AC65D0000B2 for ; Wed, 14 Jul 2021 19:36:21 +0000 (UTC) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16EJVWTh022332; Wed, 14 Jul 2021 19:36:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=QF58l7lLOjz1kbBPHdHIdxCeV2ODkZdvt4bXLCnoySs=; b=g2SSLIdzkTeskzsE+vk0hGwkdn/Uwgx0pv23vOVgfZRY0EXCIALfLRB+YDv6Ffg41tfN iIjshxBh60Y9U91IX2z72Mj96yLpw11rSJwXWFXZutcvSCoeMyCg4Oz/TvvLs+jUVNHS ShN6VpPgBaHLwK4Q2lV9hPDy9+63XZsgaWfpmlSCN8JGmLcXY63gfKOE9UAFVMJd9E/I nGgzzpp21z2oVIE5Vb6Bznt8HaQlGMgdXalZvDrDwc09dkBZfYV2oGVHPhhydYECkfNm vqt6aW/oNvq1vn3VrL/N9hhKXHVn3GG40G0pyLy4SiippgYZF9M8tBomzR7My+d7qtf6 7w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=QF58l7lLOjz1kbBPHdHIdxCeV2ODkZdvt4bXLCnoySs=; b=F2b5PseRbQpjJ3+CnXBci+DtmywG3/E5w3hCb0zlVljndW9l50nJ+RSimX0YihB3mU2U HmXSEoAlO3humR2rXWMf3LBumTgUip5hPP7bYgE5Tyj+FZAqGInwJLOttsxOO1gBCWK5 C3lIMlqi51xx+Wqi3AxYbJZStM1FCEcXOpxjAXwVHXhx7OP7veotB8NKSdnf7iwuU6mQ n2NVOy7xX0t1FW4s5Un87F/T4do8UJqohEJFYioy24zRKCPuIQlY6FZhochn9ZSyxDTU NoPPN7od/esAU27mIEYLQOVfZ8nAyfHA0hJofoZoTrojDfdyQMn08nKAIq7u6PC8yz7o RQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 39suk8sej3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Jul 2021 19:36:05 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 16EJV0dW187598; Wed, 14 Jul 2021 19:36:04 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam07lp2040.outbound.protection.outlook.com [104.47.51.40]) by aserp3030.oracle.com with ESMTP id 39qyd1c5dv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Jul 2021 19:36:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NbaK+L8d3F2l4Ed8FhkWh5phuPHO+UiFgSG83imBVHpvbg9Ohfg6xIA+0zQVr/di3uwqEJwtDs5Pqd8kvyEaUmtHroMQNhiqrVlxiGHlF2iAvyAI2oXHe/Y6+T0O888DEgIR7jQaqCdJWotFBsSS7JduC9zBnyh+l+Q4mdLAHXtdc0BtgfB0xL52SUiiJhXW4mveb+DwF/YxV4tRnsGU9LQPrdESKyrhzaQfA3MM0r+1wVyYt+pvf8nzG3WFsEW9R3yV5dr5kctQcZ4SiQM0xcR9xIaCuyRQkbdUMSVRfDAWIfsaADYFfUq6cB8E/JzGZ1vApjFwVa+ULCAlGqHOLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QF58l7lLOjz1kbBPHdHIdxCeV2ODkZdvt4bXLCnoySs=; b=T/XA2C2NQtpolICafVe9PIO0h2FMa9Z1iF7JzdiB/dUykV2BAzDF+m1JEyCOCD68fsndoPTansLPw6wa0GF2zVtG4ExzuoxwiI+2P/bELTWzIRyBoEq2VAFhkC4X/Y3pG/QJSk+OKD4oG1ys+53yDaosqAy71x3/jgnPOpmdNU9twPmvyTXRszPz5YwknogVuJ7tQim50NXzp/Jxe71LhfHIpxHUo/JQH2KT4e45cjtQ1MTODcn4v+fQtr10RNcQOVXxO4Ik7NZ+b0pyAnT3UlojKTkyCjacqu74T8u2mWcyVFMt067lfhASUnPcz12HvCM2ZFZgX0X3BOBKh86Kiw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QF58l7lLOjz1kbBPHdHIdxCeV2ODkZdvt4bXLCnoySs=; b=JdjrS06DMzRd+IcKEiZKPBgKu5MR+6qXSPLlE8qgCl9JizgrScyH9r3zjKJAjcaMMaFmgb40GTaaydKNayF49K0hzwA5f8LvDyAjynsN7TSvn5u/pROi6nHO1dbPqbqkDkkqBMeA68MnQemqbEULPB9wFP5CVD0gAG4fsK342KQ= Received: from BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) by BLAPR10MB5204.namprd10.prod.outlook.com (2603:10b6:208:328::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.22; Wed, 14 Jul 2021 19:36:02 +0000 Received: from BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::5833:5ab2:944c:7360]) by BLAPR10MB4835.namprd10.prod.outlook.com ([fe80::5833:5ab2:944c:7360%9]) with mapi id 15.20.4331.022; Wed, 14 Jul 2021 19:36:02 +0000 From: Joao Martins To: linux-mm@kvack.org Cc: Dan Williams , Vishal Verma , Dave Jiang , Naoya Horiguchi , Matthew Wilcox , Jason Gunthorpe , John Hubbard , Jane Chu , Muchun Song , Mike Kravetz , Andrew Morton , Jonathan Corbet , nvdimm@lists.linux.dev, linux-doc@vger.kernel.org, Joao Martins Subject: [PATCH v3 02/14] mm/page_alloc: split prep_compound_page into head and tail subparts Date: Wed, 14 Jul 2021 20:35:30 +0100 Message-Id: <20210714193542.21857-3-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210714193542.21857-1-joao.m.martins@oracle.com> References: <20210714193542.21857-1-joao.m.martins@oracle.com> X-ClientProxiedBy: AM4PR0101CA0048.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::16) To BLAPR10MB4835.namprd10.prod.outlook.com (2603:10b6:208:331::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from paddy.uk.oracle.com (94.61.1.144) by AM4PR0101CA0048.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4331.21 via Frontend Transport; Wed, 14 Jul 2021 19:35:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 68f4687b-2fb3-40d0-15a3-08d946fe9d15 X-MS-TrafficTypeDiagnostic: BLAPR10MB5204: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1284; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: W4402u+lEF6pNB/KvYG/27tem37/Dz3TK4hf/6uOKB7ylMdEAL/7LDqemvBrZ818OLzZGnB3bQvqlZRZQfhVa3z270z8MiiVWjjYJqjeKbUrGbrvt0+jw+/cYwVTPTTD+QJFS+K/ZGsH4dv+f6XVsw9tuzai8P4ngjaTLsoyP2uicU4rlO06BW5qd7oClxCSFq5VrWjoKDIi5FYRjTQhrUvT0yffYkdEWFrr+KjIdkSzXR8l+cfMflzYsqIvRV73AlvrLjVkdECEKi34TTnytsV5tEY9B20Xkb9qT5etU6pScOulpiV2DGLZ/6FZRm3/O2yUIHK4oLCVUUEYGn1urgdaj+YqkHqoLGJ+XtmyEQaB6CN0qGMQGZsbP9H/p26zgLTUfOaISEnkbac3SlgIJs86pNhKJZasNZCX4AbRPaGHki6NjxlMR8ERZOmAcdV2whRhVyofJYfhwSvW3xGjJ5LqGSIO8izchpvGtx+smqriQpHY306O5RS0ltamdWFklZId+7wLBGPys9AirsmjvLT0dybjQGFAJh/Xii/BO4fKbuurpOMZ+ky5YOMyZZUcU5pE0Wk/x9Zix03nqnXGoqsYrTmLITK7m4nzx+fDTpH+PaK+DCnZ6JNO9C+i3AOQMPUanhvweNgxvK1USIispKiea+BAVDWXt8Jy8zna8Vr6XLBMbVS2torS7B/c9se2EXe7t6IDiShuLQ3QgbCTsQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB4835.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(39860400002)(346002)(396003)(366004)(136003)(376002)(8676002)(4326008)(86362001)(6916009)(7416002)(2906002)(956004)(107886003)(2616005)(6486002)(1076003)(8936002)(66476007)(5660300002)(36756003)(103116003)(83380400001)(38350700002)(38100700002)(54906003)(6666004)(66556008)(316002)(66946007)(478600001)(186003)(52116002)(7696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xGQ2mEX+tATR6+fTXBtkGx2FwaS0X7vzy0TybcjG/BhrCNkMFaMXYUGuXpkmLww4NsBaNHqF846G4G4JgVtjjyJk2X/2H613nWgt6YZ7S+scjVs6JCbt2CZEZVIOpCDTh5Jbvf3dnr0wPnYnxMLLQXwXp/E5A6M/Ybz/4vN06GB5qSK7M3kdEVX1UvMytYalr4xScVpcop12NdhPprDl3KeJWpGnoo45b7XziNwFw5fUaaVgS74pJl1VUTEhJo/WnzsFwDe62HNGn5u8YTExJcLbdIB2KCBqwQsV+wiFs/JVnXhUej8PmIVlMWJEIztFsWgPCTA1kr4sgbFHbVk+9 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 68f4687b-2fb3-40d0-15a3-08d946fe9d15 X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB4835.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2021 19:36:02.2888 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HEdCe539MzOzuQy6AG0upgUaUH3ZAzDNupiLO0V4Px571kd+OsY9aFafMrA6l1QDDmIvITDtdgrw1L56L3GcaFKPsQ7bFCvIy1s/cTvfD6c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5204 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10045 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 bulkscore=0 mlxscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107140115 X-Proofpoint-ORIG-GUID: mpdWGPn4O0DOK9HHpSBtNXM6pFrP1MKR X-Proofpoint-GUID: mpdWGPn4O0DOK9HHpSBtNXM6pFrP1MKR Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=g2SSLIdz; dkim=pass header.d=oracle.com header.s=corp-2020-01-29 header.b=F2b5PseR; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=JdjrS06D; spf=none (imf20.hostedemail.com: domain of joao.m.martins@oracle.com has no SPF policy when checking 205.220.165.32) smtp.mailfrom=joao.m.martins@oracle.com; dmarc=pass (policy=none) header.from=oracle.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 2AC65D0000B2 X-Stat-Signature: fo5y3dukah9x51y1nru9qjw9d9txh1rk X-HE-Tag: 1626291381-367331 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: Split the utility function prep_compound_page() into head and tail counterparts, and use them accordingly. This is in preparation for sharing the storage for / deduplicating compound page metadata. Signed-off-by: Joao Martins Acked-by: Mike Kravetz Reviewed-by: Dan Williams Reviewed-by: Muchun Song --- mm/page_alloc.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 3b97e17806be..68b5591a69fe 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -730,23 +730,33 @@ void free_compound_page(struct page *page) free_the_page(page, compound_order(page)); } +static void prep_compound_head(struct page *page, unsigned int order) +{ + set_compound_page_dtor(page, COMPOUND_PAGE_DTOR); + set_compound_order(page, order); + atomic_set(compound_mapcount_ptr(page), -1); + if (hpage_pincount_available(page)) + atomic_set(compound_pincount_ptr(page), 0); +} + +static void prep_compound_tail(struct page *head, int tail_idx) +{ + struct page *p = head + tail_idx; + + p->mapping = TAIL_MAPPING; + set_compound_head(p, head); +} + void prep_compound_page(struct page *page, unsigned int order) { int i; int nr_pages = 1 << order; __SetPageHead(page); - for (i = 1; i < nr_pages; i++) { - struct page *p = page + i; - p->mapping = TAIL_MAPPING; - set_compound_head(p, page); - } + for (i = 1; i < nr_pages; i++) + prep_compound_tail(page, i); - set_compound_page_dtor(page, COMPOUND_PAGE_DTOR); - set_compound_order(page, order); - atomic_set(compound_mapcount_ptr(page), -1); - if (hpage_pincount_available(page)) - atomic_set(compound_pincount_ptr(page), 0); + prep_compound_head(page, order); } #ifdef CONFIG_DEBUG_PAGEALLOC