From patchwork Tue Mar 30 21:36:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Yznaga X-Patchwork-Id: 12173931 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 176A7C433E3 for ; Tue, 30 Mar 2021 21:28:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A9A646196C for ; Tue, 30 Mar 2021 21:28:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A9A646196C 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 A64C16B0092; Tue, 30 Mar 2021 17:28:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9EF846B00A7; Tue, 30 Mar 2021 17:28:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7CD146B00AA; Tue, 30 Mar 2021 17:28:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0001.hostedemail.com [216.40.44.1]) by kanga.kvack.org (Postfix) with ESMTP id 4CFB06B0092 for ; Tue, 30 Mar 2021 17:28:32 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 0F2DB181AEF3F for ; Tue, 30 Mar 2021 21:28:32 +0000 (UTC) X-FDA: 77977829664.21.B866082 Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by imf17.hostedemail.com (Postfix) with ESMTP id 766E140002CE for ; Tue, 30 Mar 2021 21:28:30 +0000 (UTC) Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 12ULNs0k130344; Tue, 30 Mar 2021 21:28:10 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-2020-01-29; bh=DSGc7PTDZdYXBU2D0khCKJfHd3zVnsm62bMxQv2PtyI=; b=DYOujjE9TSqj28AzJ6onyeR4SlGuObEMBmWCb1PG+lvHDDMMPCnrt1kyRboxEMaBJWry p/A85dbbz6P7rwYFaaSUO3+QFsqwhWwFNhOYg9Y8GB7BiLecN33+L9jWJ76E7frcltM1 8R6diKMUcb2xw+3g7ayJ30q83wcu4JbYnYYIsuFanZx6Fth8p5BVqvOom/gcCwEqjCCu ftEdU9aOpr2lk+qcFC4bxJPwLcMtqSpuUZzuGG8TVKDs3NC7a2lzswRwyvyZAAwdECmb AY3Ud10ejOL81TRmFOETNIs+fFoxfvU377twTYSqh+L8PKcHzLtu7ONF4kpWXyjYKXne Bw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 37mabqr8s2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 30 Mar 2021 21:28:10 +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 12ULPZb2124960; Tue, 30 Mar 2021 21:28:09 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2040.outbound.protection.outlook.com [104.47.66.40]) by aserp3030.oracle.com with ESMTP id 37mabnk8j3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 30 Mar 2021 21:28:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QJGecd626mc2Sg1N/nTh/TvHl8Zbkj77pXPvag5XTzHI+Aybh5FZsmbDS1Yl9G9Gf2ZvdX+8YDmYbNeK14OXk5yBehQKvKHkEvV6vgb+6z3yt2W2w+lQ3uSMMsSOEfaOoEfklBrPU0HEQYekXHZc2xCMMkPEHuV3g8KF8Akh7Ql3Xn9dVzsmZ8QI59Ht8TdCEXxJXgqk8nYpOwqg4eyCSR9eWpBL38pWzeFc3IybcvS/ptkOu2FATrcGLwdoSKnFyvzbno3HEkbzBeYXqmMqS3quZIbQ6KYNHLp9IrWHWE2PCzP2+njux36q1botXtEr9oWN4aT1KAuyeg+dLEvchg== 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=DSGc7PTDZdYXBU2D0khCKJfHd3zVnsm62bMxQv2PtyI=; b=hkp49QV3QL1lPx5ZAIXu6tl02tRs9IXqUz8gmTpGaenQss4KrZsbb7utyXAG4dk33zFyqwN9w4P6gWb1gmL16779QuwA3u3q+y3Xa/kn2XMtrkuiGKlx7wVPjpji3i7eTJWyuSRtmWNaIeXH1nhjgV7NcDc6b/2TkJMSgxahMnDgi+FffbGl58UBGB5OYEIxOpOUEaoyqo1XK2XffgygSynykJLRGi8c3wv14tc5GMKz3+C+APTawFe5fLoVMttARUHIJ1nlT7PqIn3u17AAV3R0Nf5FwGQXtqAb8vZukPxUFQhaDBsRi5aEZbZDubiHMRxMvvlkcmoy0ahKXI0Daw== 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=DSGc7PTDZdYXBU2D0khCKJfHd3zVnsm62bMxQv2PtyI=; b=zvE/kMrmF0LUlDTfZRycqNhPxiq/M398+re9ciBfNPKSeaiOoWCzhWRlxJz0qLZPG3KvMIzn+dh5wWVZ/m748/eZpkKpHmFU+whlR+9Z15ojjVmL0b5BrS4o5GGJmAMiWTg6iaEa/etfpubF9TgRYW4qtQ+vHlSj/ar1Fqxlf9Y= Authentication-Results: kvack.org; dkim=none (message not signed) header.d=none;kvack.org; dmarc=none action=none header.from=oracle.com; Received: from MN2PR10MB3533.namprd10.prod.outlook.com (2603:10b6:208:118::32) by BLAPR10MB5265.namprd10.prod.outlook.com (2603:10b6:208:325::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.26; Tue, 30 Mar 2021 21:28:07 +0000 Received: from MN2PR10MB3533.namprd10.prod.outlook.com ([fe80::cc79:c40e:430f:e254]) by MN2PR10MB3533.namprd10.prod.outlook.com ([fe80::cc79:c40e:430f:e254%4]) with mapi id 15.20.3977.033; Tue, 30 Mar 2021 21:28:07 +0000 From: Anthony Yznaga To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: willy@infradead.org, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, rppt@kernel.org, akpm@linux-foundation.org, hughd@google.com, ebiederm@xmission.com, keescook@chromium.org, ardb@kernel.org, nivedita@alum.mit.edu, jroedel@suse.de, masahiroy@kernel.org, nathan@kernel.org, terrelln@fb.com, vincenzo.frascino@arm.com, martin.b.radev@gmail.com, andreyknvl@google.com, daniel.kiper@oracle.com, rafael.j.wysocki@intel.com, dan.j.williams@intel.com, Jonathan.Cameron@huawei.com, bhe@redhat.com, rminnich@gmail.com, ashish.kalra@amd.com, guro@fb.com, hannes@cmpxchg.org, mhocko@kernel.org, iamjoonsoo.kim@lge.com, vbabka@suse.cz, alex.shi@linux.alibaba.com, david@redhat.com, richard.weiyang@gmail.com, vdavydov.dev@gmail.com, graf@amazon.com, jason.zeng@intel.com, lei.l.li@intel.com, daniel.m.jordan@oracle.com, steven.sistare@oracle.com, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, kexec@lists.infradead.org Subject: [RFC v2 43/43] PKRAM: improve index alignment of pkram_link entries Date: Tue, 30 Mar 2021 14:36:18 -0700 Message-Id: <1617140178-8773-44-git-send-email-anthony.yznaga@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1617140178-8773-1-git-send-email-anthony.yznaga@oracle.com> References: <1617140178-8773-1-git-send-email-anthony.yznaga@oracle.com> X-Originating-IP: [148.87.23.8] X-ClientProxiedBy: BYAPR11CA0099.namprd11.prod.outlook.com (2603:10b6:a03:f4::40) To MN2PR10MB3533.namprd10.prod.outlook.com (2603:10b6:208:118::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-qasparc-x86-2.us.oracle.com (148.87.23.8) by BYAPR11CA0099.namprd11.prod.outlook.com (2603:10b6:a03:f4::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.26 via Frontend Transport; Tue, 30 Mar 2021 21:28:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a0a8d607-5eee-4e19-2be3-08d8f3c2b59a X-MS-TrafficTypeDiagnostic: BLAPR10MB5265: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2043; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: U/QQ2mFjJdy9NMFDoLwwnFyudM5JzqRl07czgKAZQgitQ1g/RTdMQvK3Q02wZriGnUgfDkeAGP4WVCSBQQ2+kmzSG1umRHYOJ9Nz+AgzQpza/ylxtOoVIgIfmjHfA4KUKia0z3i/yO0c+2WZsmIyxlF1YPFZfj0B5oRpUx/FLU/V2SuPvSh6mYCSuV5X9RP6S4tPLNdnsR7xLb/iwkxkI0cPPvXQGZXDfAd3RYDN2KMDofqH/zDXluphojrDdVlVl7V+418d+VqGjdNoBaGGjihSScDgFrot33QJNl/qgEmJZmam7aOK51zZHXDGMyISzS84PmH5XQgdWBR/bXPN13zKCfjduwhkEpE7+UgyF4Ftpk9JW6tesBGPHK8fHxB3j4ozoNEBxWpsqsXQlIrsxF/DmXjOk7EHm+UJIwSnXlSNFcjXMoUu0ZNphefRTrpg6Rmc54LLzrFhAAI/KiqZhm9pu8Yw31Cse7er8/yD+oBHfOaaYZ6hJFppwUrVUe6nTj7e/LaLGrPzDYOqN3nUgnRN/eHISHufsqcoKbg6secCPwer2Ceardgie42/iuvl1k2wXy2bEHhRan00g7mOFttj/j3W/XbSCXGDsZTN3FX9GGai8om99LnPcJnVlajzFRu6w0IRLJsYKJ6iq6+Kpw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR10MB3533.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(396003)(136003)(346002)(376002)(39860400002)(26005)(956004)(52116002)(186003)(38100700001)(36756003)(4326008)(8676002)(44832011)(2906002)(316002)(66476007)(2616005)(7696005)(478600001)(8936002)(86362001)(6666004)(83380400001)(7416002)(66946007)(5660300002)(16526019)(6486002)(7406005)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dGY4+ZLjt5TGmg1h32o31S6etICxBVlIVWebOdnfkYidWAJ1XrJNkMEizfjfaTHvYB31ipfshMQZ7h1zcpBYRgRNBUjrFeZ/KlKEtFZl2amVd6s12wxMjefvSnlZNsUw+iNAj9ew0robRTQsVQ9D071Pwe9RoUHePhHZ0ypuX7NmZWBiAx8i5ri+JPJNNL8SKV0TakkUYQKk6oy5DuOpxBYGlvIiF+nPc5TtsnsN6nvNXHHtY2K345afOfdl3NevBuWIyjZtCQiB4QP6NqMTPVJwYfZ7z5p2Qg/SXs8l/UL9idT7NZtenNoP X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0a8d607-5eee-4e19-2be3-08d8f3c2b59a X-MS-Exchange-CrossTenant-AuthSource: MN2PR10MB3533.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2021 21:28:07.0639 (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: 6c0Vc660uRerXcRqD49W4MZvBtUBknhiafKQGZhr51i/42P1Fr3OD+WCniVjMBm3Z0Q5Je8aV5rdCYNEDbXVU2rK+ISd2XsKTU4EWpv4OLs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5265 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9939 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 adultscore=0 spamscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103300000 definitions=main-2103300156 X-Proofpoint-ORIG-GUID: BVK1iEZHg5ovKmvclLpOhn-Rb5_GIDS1 X-Proofpoint-GUID: BVK1iEZHg5ovKmvclLpOhn-Rb5_GIDS1 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9939 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 suspectscore=0 adultscore=0 mlxscore=0 bulkscore=0 spamscore=0 clxscore=1015 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103300000 definitions=main-2103300156 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 766E140002CE X-Stat-Signature: om6cw7rozhdmrzfrs7dgfntpngjbphez Received-SPF: none (oracle.com>: No applicable sender policy available) receiver=imf17; identity=mailfrom; envelope-from=""; helo=aserp2120.oracle.com; client-ip=141.146.126.78 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1617139710-588949 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 take advantage of optimizations when adding pages to the page cache via shmem_insert_pages(), improve the likelihood that the pages array passed to shmem_insert_pages() starts on an aligned index. Do this when preserving pages by starting a new pkram_link page when the current page is aligned and the next aligned page will not fit on the pkram_link page. Signed-off-by: Anthony Yznaga --- mm/pkram.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mm/pkram.c b/mm/pkram.c index b63b2a3958e7..3f43809c8a85 100644 --- a/mm/pkram.c +++ b/mm/pkram.c @@ -911,9 +911,20 @@ static int __pkram_save_page(struct pkram_access *pa, struct page *page, { struct pkram_data_stream *pds = &pa->pds; struct pkram_link *link = pds->link; + int align, align_cnt; + + if (PageTransHuge(page)) { + align = 1 << (HPAGE_PMD_ORDER + XA_CHUNK_SHIFT - (HPAGE_PMD_ORDER % XA_CHUNK_SHIFT)); + align_cnt = align >> HPAGE_PMD_ORDER; + } else { + align = XA_CHUNK_SIZE; + align_cnt = XA_CHUNK_SIZE; + } if (!link || pds->entry_idx >= PKRAM_LINK_ENTRIES_MAX || - index != pa->pages.next_index) { + index != pa->pages.next_index || + (IS_ALIGNED(index, align) && + (pds->entry_idx + align_cnt > PKRAM_LINK_ENTRIES_MAX))) { link = pkram_new_link(pds, pa->ps->gfp_mask); if (!link) return -ENOMEM;