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 CD68BC3DA4A for ; Mon, 19 Aug 2024 11:43:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 41AA46B0083; Mon, 19 Aug 2024 07:43:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3CB746B0085; Mon, 19 Aug 2024 07:43:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2919C6B0088; Mon, 19 Aug 2024 07:43:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 0C3896B0083 for ; Mon, 19 Aug 2024 07:43:10 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A6388411A8 for ; Mon, 19 Aug 2024 11:43:09 +0000 (UTC) X-FDA: 82468808898.30.91419D3 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf23.hostedemail.com (Postfix) with ESMTP id B4518140024 for ; Mon, 19 Aug 2024 11:43:06 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf23.hostedemail.com: domain of jonathan.cameron@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=jonathan.cameron@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724067701; 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=uGSxUaJugfWuZNCzN12E9bviUkxMcEcgjd9+AmTKMrI=; b=C5V7+4PzFD+0BqVItKow0phs57vrutOuDkfbNvWNgGi5LO7bizHkxjCOujE+3zBwrFKmst jQqsP+1u1AciW27WudxmEg/kvDdkuAQdvWllvTGIJ3ErXTxzpIGMKlC+ovcvVVZC2DG4/m Ckm3V1SvYTQcbddtLh1lCp/GemJ5XTo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724067701; a=rsa-sha256; cv=none; b=lf6DQHASbY3Q2Bo4eiXyj9ICddacfo/+kBd3d4XEaGEc82G0hm1vzaGC0oTqe+aAqp1TuJ 5gnKrF4HjtuOZiTlh2ewSDcV+sXsM6vEZlb8hwvVScoHLonZpKWz+83spR63BMrH1C2kLe H03SjYKTJGvI7M4zhN7soUsr3jKh8sE= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf23.hostedemail.com: domain of jonathan.cameron@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=jonathan.cameron@huawei.com Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4WnVxZ2DT9z6K6GP; Mon, 19 Aug 2024 19:39:30 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id 711CF1400C9; Mon, 19 Aug 2024 19:43:02 +0800 (CST) Received: from localhost (10.203.177.66) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Mon, 19 Aug 2024 12:43:01 +0100 Date: Mon, 19 Aug 2024 12:43:00 +0100 From: Jonathan Cameron To: Tong Tiangen CC: Mark Rutland , Catalin Marinas , Will Deacon , Andrew Morton , James Morse , "Robin Murphy" , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Michael Ellerman , Nicholas Piggin , Andrey Ryabinin , Alexander Potapenko , Christophe Leroy , Aneesh Kumar K.V , "Naveen N. Rao" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , , "H. Peter Anvin" , , , , , , Guohanjun Subject: Re: [PATCH v12 3/6] mm/hwpoison: return -EFAULT when copy fail in copy_mc_[user]_highpage() Message-ID: <20240819124300.0000421e@Huawei.com> In-Reply-To: <20240528085915.1955987-4-tongtiangen@huawei.com> References: <20240528085915.1955987-1-tongtiangen@huawei.com> <20240528085915.1955987-4-tongtiangen@huawei.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.203.177.66] X-ClientProxiedBy: lhrpeml100005.china.huawei.com (7.191.160.25) To lhrpeml500005.china.huawei.com (7.191.163.240) X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: B4518140024 X-Stat-Signature: o9ptgod9ahcdez3i4p3b4qsuw9rjzyoc X-Rspam-User: X-HE-Tag: 1724067786-772409 X-HE-Meta: U2FsdGVkX1+K2KTehiZVUxUmmZa+NvmZdYxldPuhnmTXKLy39hnrhhhNcrDIjVmYSXh6X4wh+rPkHvrxTPEQVmlRK97Lihc8WZRgZ8vgXSD0FJ4/XxUTECx11kY0+NjWtyhAk62eHopF/1+FgBLnVxWbIuiekLyZtORqSjWrP/9ccRvFxMdV7QVq1dVjLDakeTij1yVTGBXyTh04ctetMvLK4tnxtIsKBrzf/cFFv0/5QEe20je2wyOc2oQY9qBH9fTr/uOGbj1EQ5NXalVd3pGLIRXw+bniwf1LP6TeK0xWrFll6r/92vkSk449nv6KfCVD7kqRIo0DoSFZqxHvaAsufq1Eik3SjXUr3TCxXj04/PcE6YURgf3BjDRWcISD9BpAy21E0N1eqX6BNsHpwZ2cdhIODTbSK3DDwlyvy8Yx33PXpth7lkQ+r5A9EJPss18NVT+KKo43ny04oAyVF9R/nslqFJSD58N5qulK6gUqU772MUBi3OvZxrgSDQQJ7UXsf9ZjmqFt72/8G6Gc/dcaAP++C7s3uuNeggQ5drzDGunDnMKsjuFz+75G3x7MLoN9TiMDtR3y6zsw8M+7LNpKlcJeWHsERB1s53/vbScWSJ9h4l7Dq3YPf/io3LxEu4xKDU5LJaLadd59f8sN8aF2p1GV8LmDvq4mop0/dqMCHgdw7Kh4pmtyiij+ZKEuOUFsH3IT1Qjg7o5O6nSCJ6iG+v5/cEkZzdsadkt9zqtBJq3AEApBrPMKLDmaP9+0NXeWi0CLnpW8QnEiEYjGMDz4cVBDMrzqB+k+zcjL1lfXqgjMIMjOvv6yQxKWzd4bfZp3KnBYYsfrlqlvqRhg7s1wDDIFT4G8fqUUj7QKXILSi/cj8v96ylUm3T7jy0UHv3RMcpR6z3cDJbmf2EmSeYtzwOU37oUGktxPoDF+hI7gBaCFdFF4ISFQ/yFNCSHkxonu5BAdhDV1taRxFj6 621RQvkX K8eydoQow3paI3vzfmdsba0sseCmUs37OX1BZeYYmKX4trRhIiCWxr5YCSSQP/YKtGpzmFQSyfSNk3WIGhElhpWwMn1LyEXEU9Q7W63b2oC0dlBoFLZ//CyaP41GWjmrptOWpyxhx/qDOUWcn9ZNX8njM/+10ZkEh1CI5RjcHfGamMtdjvi99lOfF57pGdrcOeh3qQW8tM2b1C5beTjq0U1xX48uiAsFft4NCqDrwipYhusE1Wyw9NTj3YJqicaJ2W9wFiNtqynP834SeCJJvX4twdQ+N5VT7w0K8J/d0GjhareqvK/FtwOYzvsBdeS5wse6qrVJmN3HGsd4c7eH+gfkgheJPPS4qLrnL6HC0Qlq/y6TgO2+/Pn7ZOXJ6IAl+SPOd 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 Tue, 28 May 2024 16:59:12 +0800 Tong Tiangen wrote: > If hardware errors are encountered during page copying, returning the bytes > not copied is not meaningful, and the caller cannot do any processing on > the remaining data. Returning -EFAULT is more reasonable, which represents > a hardware error encountered during the copying. > > Signed-off-by: Tong Tiangen LGTM Reviewed-by: Jonathan Cameron > --- > include/linux/highmem.h | 8 ++++---- > mm/khugepaged.c | 4 ++-- > 2 files changed, 6 insertions(+), 6 deletions(-) > > diff --git a/include/linux/highmem.h b/include/linux/highmem.h > index 00341b56d291..64a567d5ad6f 100644 > --- a/include/linux/highmem.h > +++ b/include/linux/highmem.h > @@ -335,8 +335,8 @@ static inline void copy_highpage(struct page *to, struct page *from) > /* > * If architecture supports machine check exception handling, define the > * #MC versions of copy_user_highpage and copy_highpage. They copy a memory > - * page with #MC in source page (@from) handled, and return the number > - * of bytes not copied if there was a #MC, otherwise 0 for success. > + * page with #MC in source page (@from) handled, and return -EFAULT if there > + * was a #MC, otherwise 0 for success. > */ > static inline int copy_mc_user_highpage(struct page *to, struct page *from, > unsigned long vaddr, struct vm_area_struct *vma) > @@ -352,7 +352,7 @@ static inline int copy_mc_user_highpage(struct page *to, struct page *from, > kunmap_local(vto); > kunmap_local(vfrom); > > - return ret; > + return ret ? -EFAULT : 0; > } > > static inline int copy_mc_highpage(struct page *to, struct page *from) > @@ -368,7 +368,7 @@ static inline int copy_mc_highpage(struct page *to, struct page *from) > kunmap_local(vto); > kunmap_local(vfrom); > > - return ret; > + return ret ? -EFAULT : 0; > } > #else > static inline int copy_mc_user_highpage(struct page *to, struct page *from, > diff --git a/mm/khugepaged.c b/mm/khugepaged.c > index 774a97e6e2da..cce838e85967 100644 > --- a/mm/khugepaged.c > +++ b/mm/khugepaged.c > @@ -798,7 +798,7 @@ static int __collapse_huge_page_copy(pte_t *pte, struct folio *folio, > continue; > } > src_page = pte_page(pteval); > - if (copy_mc_user_highpage(page, src_page, src_addr, vma) > 0) { > + if (copy_mc_user_highpage(page, src_page, src_addr, vma)) { > result = SCAN_COPY_MC; > break; > } > @@ -2042,7 +2042,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, > index++; > dst++; > } > - if (copy_mc_highpage(dst, folio_page(folio, 0)) > 0) { > + if (copy_mc_highpage(dst, folio_page(folio, 0))) { > result = SCAN_COPY_MC; > goto rollback; > }