Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp2371397pxy; Tue, 3 Aug 2021 05:01:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxi1YJzmqMu5dRKh4zM64Gwan1YZTKk1jtJ2omT0GeO+BBrQ7KIItXuw2cK5Rfef6hDZNBg X-Received: by 2002:a92:c005:: with SMTP id q5mr960512ild.117.1627992112360; Tue, 03 Aug 2021 05:01:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627992112; cv=none; d=google.com; s=arc-20160816; b=Wof9OsbleYOmufCNz9/+6s/hjS0J1IEOH5HMyA5paPhIklqXxGIW5FngGDxbb0NIRm 1flqHAdw3qEuxMKVi/dD7Oh9boXNfeuzDj4KBubvMNBja6Q8EDenxH/7etAlDho54MMa hK5c0y1D6iXp8sw+J0vB08FUtwXiErHLA00gkC2pTh9ScMknNzesOfxGDv3IAVXjRLQd TBmTiDEYZquyD6ODlE6pWjPnu2JgsWH69tED4K47dp2PaEVMACHR6d7HeQB06mYOX35R pndOEwYoWtRjBoNK+UOypXXqy4Srpt1AvKYa276YS3FWzMN4T1nk1aV7/fghhaAvsM9T N12Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=mWWcG5RvzZnZtzlTEpwyxElez8u4/J5+F8NGP5+ob2I=; b=ckfnv/uTn3qXPKolC6BmMPbHGs9MpEpE9u5Op5LJvMFW7Z04BB3k8UYB5zUVxiVUcG 7HJ4uzaeuAghrY+6L4I2TK9XjwdTr8rGslfdaQXHjsOkLf6348M3tWhVsheEJGw0+xtE F+0Mt1TLPdGId7wmQJ6DJO868306lobG6Nml5QkRBL59YoagpOfokWqL+bOvCdqLVh/o 3+Zs3ynyF/oWGyxIU3O3A9sjRK9Z3WzkUp0/QXDIFLxLRNkIMHvPHSZBfgRDDQ7VYZA6 8KSR4KyiaDZYRVjpopkXRgGQkvCIO0eOFPSVhrLO424V9um6YOPbVzHrx3zPSdkOVR9Z z85Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=HrXnZbf8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z9si13977037ilu.28.2021.08.03.05.01.38; Tue, 03 Aug 2021 05:01:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=HrXnZbf8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235787AbhHCMA7 (ORCPT + 99 others); Tue, 3 Aug 2021 08:00:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235709AbhHCMA7 (ORCPT ); Tue, 3 Aug 2021 08:00:59 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34C99C061757 for ; Tue, 3 Aug 2021 05:00:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=mWWcG5RvzZnZtzlTEpwyxElez8u4/J5+F8NGP5+ob2I=; b=HrXnZbf8ZK+Qr50SSMhpEZCtgU l0YFFCxnK++awS8wJVr5m49RsENKHlMUb5wHA6U/ljSvInTXQabW2yyEp7b5/2XlgTBKSS6frG03k evTCgGgRDnmjsR4++F8tjEEPEYWdG5WYpldllArWVwMyoGKNaFl8lnUQ9iHqOFBJ8+xa3rMs5x4HK w5gozJoYw9BKU2ha1loKSuDyyRrzs2+gtE2maPM9rJ9jpYkFNII7Rmp8y7nSH081PCMOTnAOOrCkK ZJNLBDpgumgWyD+bBdPiwt38iDoLU94Pc19NDF7M2892jtQja3pfewd0l/IQzjk+m2x83pHawSeCf nQEXC+0Q==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAt4g-004bvm-21; Tue, 03 Aug 2021 11:59:17 +0000 Date: Tue, 3 Aug 2021 12:59:10 +0100 From: Matthew Wilcox To: "Huang, Ying" Cc: Andrew Morton , Hugh Dickins , David Hildenbrand , Yang Shi , Linux-MM , LKML , Miaohe Lin , Johannes Weiner , Michal Hocko , Joonsoo Kim , Minchan Kim , huang ying Subject: Re: [PATCH] mm,shmem: Fix a typo in shmem_swapin_page() Message-ID: References: <20210723080000.93953-1-ying.huang@intel.com> <24187e5e-069-9f3f-cefe-39ac70783753@google.com> <877dh354vc.fsf@yhuang6-desk2.ccr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <877dh354vc.fsf@yhuang6-desk2.ccr.corp.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 03, 2021 at 04:06:47PM +0800, Huang, Ying wrote: > As Hugh pointed out, EINVAL isn't an appropriate error code for race > condition. After checking the code, I found that EEXIST is the error > code used for race condition. So I revise the patch as below. If Hugh > doesn't object, can you help to replace the patch with the below one? > > Best Regards, > Huang, Ying > > -----------------------------8<--------------------------------------- > >From e2b281a0b09d34d6463942e214e577ed9357c213 Mon Sep 17 00:00:00 2001 > From: Huang Ying > Date: Tue, 3 Aug 2021 10:51:16 +0800 > Subject: [PATCH] shmem_swapin_page(): fix error processing for > get_swap_device() > > Firstly, "-" is missing before the error code. Secondly, EINVAL isn't > the proper error code for the race condition. EEXIST is used in > shmem_swapin_page() for that. So the error code is changed to EEXIST > too. > > Link: https://lkml.kernel.org/r/20210723080000.93953-1-ying.huang@intel.com > Fixes: 2efa33fc7f6e ("mm/shmem: fix shmem_swapin() race with swapoff") > Signed-off-by: "Huang, Ying" Suggested-by: Matthew Wilcox (Oracle) Also, the description is poor. How about: If we hit this rare race, returning EINVAL (or even -EINVAL) would cause the page fault to be handled as a SIGBUS. This is not correct; the page is not missing or unreadable, it has simply changed location. Returning -EEXIST here will cause the lookup to be retried by the caller.