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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5EA26C3DA4A for ; Mon, 19 Aug 2024 11:44:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Subject:CC:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=uGSxUaJugfWuZNCzN12E9bviUkxMcEcgjd9+AmTKMrI=; b=BLUid6D4ixvauKeLliyZkQn8ej vvGsg7IzxPlGBSVGkLCnkoOJuhaBmK+oT0lbPdMYasOsBZDdFZJaaF0fYn76Zaskxuk4wNHjgK3U9 e1+7CGv2Cn6iVcsjJRQwC+Mpm98o7y+iPY8CeiUhyBL5CRDXodAruhDECGeM+ay+m8iNG7EbZJvfy ytkoMwffVNP5Jw31k/9qqMdUEvdR2AGaqhiHLPA603X9vdI+xmCKiIAk/gi2P+59KAsyOtkI3dGZY Cs+K51N13D1zdw2/GsBgHzo/jcOP2hNdZfgNeQw1ajibpyPbqE02U+gQOTeNFLSGbYGjnvbB5A8te vE4E2xUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sg0nx-00000001GPA-2EFb; Mon, 19 Aug 2024 11:44:09 +0000 Received: from frasgout.his.huawei.com ([185.176.79.56]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sg0mz-00000001G9A-2DfP for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2024 11:43:11 +0000 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240819_044309_868780_5322AFF5 X-CRM114-Status: GOOD ( 21.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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; > }