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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D837D13588 for ; Mon, 28 Oct 2024 06:36:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 05D726B0085; Mon, 28 Oct 2024 02:36:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 00C666B0088; Mon, 28 Oct 2024 02:36:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E3D566B0089; Mon, 28 Oct 2024 02:36:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C59366B0085 for ; Mon, 28 Oct 2024 02:36:05 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 0CCD91A071C for ; Mon, 28 Oct 2024 06:35:25 +0000 (UTC) X-FDA: 82722049830.09.27C1CDF Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf04.hostedemail.com (Postfix) with ESMTP id 07F574000B for ; Mon, 28 Oct 2024 06:35:32 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf04.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730097247; a=rsa-sha256; cv=none; b=iNStAq20mtLVGFG3X2WxN1tJIKYcBok+oamx1ogwxeIoJH4U4Vor1YGjta/uvS7W7x10/s Sy5k/0P6sLA1mE0csos6rIyy5un5mFzhl8YMqacNJ6gdlHLS11u9SbNS5vvvccEKCb0akB sPMx4VwtdTNTBMyOsG1ancgYHlbwgsQ= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf04.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730097247; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uzHz5qbLVGO2PngCteDLaf/QeoaAwnMjfEbIrXIJLRc=; b=QI3yUBR8r/YvDcYla4lundibvZRzEIpTFllUuuW9xKfe8lXnIHyvY1EA6q+nLRWfYXxuUi jWE2+8fNGp6oZ+BRUGliKy8WPsD/rzoCyyg87v1j6iSE2voHUvDYYlM7EIDPn+qpJuV4rA l2Vc73/8BfWkNmtxvugrOm1BCC2G1s8= Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4XcNnv6rZDz1HLZ8; Mon, 28 Oct 2024 14:31:31 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id 257AB1A0190; Mon, 28 Oct 2024 14:35:58 +0800 (CST) Received: from [10.174.177.243] (10.174.177.243) by dggpemf100008.china.huawei.com (7.185.36.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 28 Oct 2024 14:35:57 +0800 Message-ID: <34acebee-f072-47eb-8710-3ef1addd664f@huawei.com> Date: Mon, 28 Oct 2024 14:35:57 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/2] mm: use aligned address in clear_gigantic_page() To: "Huang, Ying" CC: Andrew Morton , David Hildenbrand , Matthew Wilcox , Muchun Song , References: <20241026054307.3896926-1-wangkefeng.wang@huawei.com> <874j4wycnn.fsf@yhuang6-desk2.ccr.corp.intel.com> Content-Language: en-US From: Kefeng Wang In-Reply-To: <874j4wycnn.fsf@yhuang6-desk2.ccr.corp.intel.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemf100008.china.huawei.com (7.185.36.138) X-Rspamd-Queue-Id: 07F574000B X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 39omhresw8k6ojjsa4tbcy45mejddhzg X-HE-Tag: 1730097332-334034 X-HE-Meta: U2FsdGVkX19dlJj2LnxKJOLeacVhAuIhVIwHWyL7rDM2ajySI6C3oLI1eLwb5tESYuFNAVL//YZIhWj6PpouFL/M3O7AdUXGXZs/CdPSEzA/dpa6BcQgLcCJP/1Kq9vqjPiOBXl4hkAYyGQj9MSU2va9yshbrhUzNRnGp0LpP/oLtCLTepk5I3eUrXfB3ijPFypbILoRaBEW7U3P5bA9OJiXXS1Ij83TRouacDJP+ef2lysOFToipLq1q4QErDmJmr8WxEoccMJHuyWQS4kngx0BHineH8NQvJUA3eNDRul025N4Rk6fH3Fl+n2/gBVnuuu76kQOkyXxDDbq8YvmGnL4ULnL5n4Z3bb3awBLJ7mREesKcVcar0nJ4o4XFT8uy3/L9ITTyf2L3XWh8cE3uwWCtGj93L2vihFuPgKPcdFVn7CPApqwrdgFyZHbiUhigRda/bCCnTC/UYUi/9LjTfYpdt+fsV4YZfiZwpMtWqDnjoFyy7YY8fxufEpIPhbcXfBtaRicY9gr08t7ujzZCEhc7p0jJwcb1Awdn5g1iunHsDTTZSZCbCB920Co9TOlhp/VH7tkf33bKnQ8Jr250yXBlqp5rO7hac3lv5Er2H5gXsf7x5DeMI6xErK96zqFIx1ZrOoQaKOlwf5QAhrOodzGFujbphUeNayCXhb/Mzm1rKVzxuicgRmWXqdXLY+SBsiZlrdmLRxbitLzC8xV6xEJtlBSloFAngl4Bm9TKOLU9cZkt37T52CvI5J9bWI4ntChLOHh1Jh7aVJs5kQA9/rWmR4GzQ7EV22K0q42nJzCsR18kclbnVCPhJIB2OxjHiyb3vYC4CbLHoXzmaI1fLC784gwYSkFHxXQCYUO1qccW4Uy1nysOOc/WSrmcGMntwPUsKZN9b6tBmCODCoVM2yHeVrDPj8R2Y19ohV0RoqFLfeq50fmpHHIO8W5MZ4fKXYGoPKhGnNNoL2gXYS bTQIpYQ+ T3ZvE/5Vrz+4FN2U2ZJLP4swko0Sd22aAL8wwhxkfbD//1zL8QK7Ns+gaR8jWimBDg3C5uWIhRxPOhBvkF/J6lXy1IMkSTYy7u53lHQt3fNXLBzOV6LBYSwiHtqQ20039yZ6YywxP5+G1LX/X4HdhmYXG/8IicNxi8dhRVG7i8FSzM5uf69ZQq/UKDOWL2ssKMSuS06lEGxola9FbcovcvDFuziJDLcEoGMIV9GKodIMMBBo= 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: List-Subscribe: List-Unsubscribe: On 2024/10/28 14:17, Huang, Ying wrote: > Kefeng Wang writes: > >> When clearing gigantic page, it zeros page from the first page to the >> last page, if directly passing addr_hint which maybe not the address >> of the first page of folio, then some archs could flush the wrong cache >> if it does use the addr_hint as a hint. For non-gigantic page, it >> calculates the base address inside, even passed the wrong addr_hint, it >> only has performance impact as the process_huge_page() wants to process >> target page last to keep its cache lines hot), no functional impact. >> >> Let's pass the real accessed address to folio_zero_user() and use the >> aligned address in clear_gigantic_page() to fix it. >> >> Fixes: 78fefd04c123 ("mm: memory: convert clear_huge_page() to folio_zero_user()") >> Signed-off-by: Kefeng Wang >> --- >> v2: >> - update changelog to clarify the impact, per Andrew >> >> fs/hugetlbfs/inode.c | 2 +- >> mm/memory.c | 1 + >> 2 files changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c >> index a4441fb77f7c..a5ea006f403e 100644 >> --- a/fs/hugetlbfs/inode.c >> +++ b/fs/hugetlbfs/inode.c >> @@ -825,7 +825,7 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset, >> error = PTR_ERR(folio); >> goto out; >> } >> - folio_zero_user(folio, ALIGN_DOWN(addr, hpage_size)); >> + folio_zero_user(folio, addr); > > 'addr' is set with the following statement above, > > /* addr is the offset within the file (zero based) */ > addr = index * hpage_size; > > So, we just don't need to ALIGN_DOWN() here. Or do I miss something? Yes, it is already aligned, > >> __folio_mark_uptodate(folio); >> error = hugetlb_add_to_page_cache(folio, mapping, index); >> if (unlikely(error)) { >> diff --git a/mm/memory.c b/mm/memory.c >> index 75c2dfd04f72..ef47b7ea5ddd 100644 >> --- a/mm/memory.c >> +++ b/mm/memory.c >> @@ -6821,6 +6821,7 @@ static void clear_gigantic_page(struct folio *folio, unsigned long addr, >> int i; >> >> might_sleep(); >> + addr = ALIGN_DOWN(addr, folio_size(folio)); but for hugetlb_no_page(), we do need to align the addr as it use vmf->real_address, so I move the alignment into the clear_gigantic_page. >> for (i = 0; i < nr_pages; i++) { >> cond_resched(); >> clear_user_highpage(folio_page(folio, i), addr + i * PAGE_SIZE); > > -- > Best Regards, > Huang, Ying >