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 X-Spam-Level: X-Spam-Status: No, score=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no 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 570BAC4338F for ; Wed, 4 Aug 2021 04:28:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 88C2B60EFD for ; Wed, 4 Aug 2021 04:28:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 88C2B60EFD Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id CE56A8D001A; Wed, 4 Aug 2021 00:28:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C6E7E8D000F; Wed, 4 Aug 2021 00:28:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B0F198D001A; Wed, 4 Aug 2021 00:28:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0127.hostedemail.com [216.40.44.127]) by kanga.kvack.org (Postfix) with ESMTP id 948648D000F for ; Wed, 4 Aug 2021 00:28:30 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 467D0180388E3 for ; Wed, 4 Aug 2021 04:28:30 +0000 (UTC) X-FDA: 78436116780.11.39E2A32 Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.46]) by imf07.hostedemail.com (Postfix) with ESMTP id 0CD01100B0E2 for ; Wed, 4 Aug 2021 04:28:29 +0000 (UTC) Received: by mail-ot1-f46.google.com with SMTP id r16-20020a0568304190b02904f26cead745so194792otu.10 for ; Tue, 03 Aug 2021 21:28:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :mime-version; bh=V7dlIRAth9sYvaZsn4KNNo84AomPSoot7o917Iory/g=; b=fdGDsSmcFrcH5p5qG8Hlu+0IQqB8/i18u3L1FMTKzhkoYJvHcZhTtZ1GsWkW6ozRNF uYm7Hgwnnz6PHTnyXlqjOzwUZNo68IXCp0oNqDQyCR2XvLVqq91lxXD6+ZF7bBSejXwT LaZjjuPa60hlf2VQEzM3CVFix1k6Fxm0B561vYD7FwEdmHbjJoTJ3eiYOh8aODxiktCP KpSlLIXhxjE6l603EQGRWX9FCo4Hkzdjsr6j5D/Xk4W24Agc9RaaviLVsxlbnuGMy4zS c64IDF/xcIhoQalKnQ6QSu8KAtQPAlREG6f9vq4pj0fozbJXxOrOraeG5L3NBbdW+VTn lT0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:mime-version; bh=V7dlIRAth9sYvaZsn4KNNo84AomPSoot7o917Iory/g=; b=Ci0/cIOPl+AAGyPeL1qK7UnYkTvaHvVEQvQVSvjXv5ejlwAVq/Eby8ToIx6/TIgrWJ Ze+/U8Vdqsp3DEcuvH2jWgD+GMelFHgxZe/yRLrqwLF5ak4rGoq3xx35xRCKmOsvyJWC /5yUB2aAqzG7quqctYvOhlzxdB0hAu1cBmbpB/aWHVqQuwjd9s8jvFaGZrcvHt7+xAIL wwuoHnEqR0lYEXachKxDPhCz0SjFvJ+ckd1DRjSoX+NuYulallIb4ZHudoOsklyuoouF hAHJh7p6w6PYmYAU/m6KYcbdBcCSmO7RY8cUl37vHG5/CryIWzPvS0veDE1Fx3Bu9fA2 C79g== X-Gm-Message-State: AOAM532PbAtN1Y/BB3xt+hBVGCCPD5W27oZwpcR+k6TO+4b5gKwV/xyf 7ZisCardjCK6UPeHMoAfzNudZw== X-Google-Smtp-Source: ABdhPJx5Hvw4eV4nN3fhfyM0o21/7qi2IboifgF1R9/Ebp17Hm6CGExEMMDBaHI6FyFurgqcZJvhZg== X-Received: by 2002:a05:6830:19fa:: with SMTP id t26mr17968231ott.58.1628051309120; Tue, 03 Aug 2021 21:28:29 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id u14sm225435oth.73.2021.08.03.21.28.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Aug 2021 21:28:28 -0700 (PDT) Date: Tue, 3 Aug 2021 21:28:13 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.anvils To: "Huang, Ying" cc: Andrew Morton , Hugh Dickins , David Hildenbrand , Yang Shi , Linux-MM , LKML , Miaohe Lin , Johannes Weiner , Michal Hocko , Joonsoo Kim , Matthew Wilcox , Minchan Kim , huang ying Subject: Re: [PATCH] mm,shmem: Fix a typo in shmem_swapin_page() In-Reply-To: <877dh354vc.fsf@yhuang6-desk2.ccr.corp.intel.com> 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=UTF-8 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 0CD01100B0E2 Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=fdGDsSmc; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf07.hostedemail.com: domain of hughd@google.com designates 209.85.210.46 as permitted sender) smtp.mailfrom=hughd@google.com X-Stat-Signature: xmeuntm8cqo6e38m4xwuxazqu16jsopm X-HE-Tag: 1628051309-40382 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: On Tue, 3 Aug 2021, 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? (I'm sorry that it's so hard to extract responses from me...) Yes, I'll go along with this version, or Matthew's better commented version, which Andrew has now taken into his tree. I won't go so far as to Ack this, because I still want to revert the original commit; but this will not do actual harm, and I'm too slow to mess you around further for 5.14. I'll just have to work through it and argue it later when/if I have time. I'll say more on that in answering your earlier mail in this thread. But should admit right now that I think have somewhat misled us all. Neither the EINVAL nor the -EINVAL were as dangerous as they looked: because they were followed immediately by "goto failed", and failed: if (!shmem_confirm_swap(mapping, index, swap)) error = -EEXIST; and in the case that get_swap_device() fails, all the swapping off has been done, so shmem_confirm_swap() will return false, and the error then be set to -EEXIST anyway. But let's pretend that I hadn't realized that: what's in Andrew's tree is better than what was there before. (And let's pretend that in writing those paragraphs, I did not realize that get_swap_device() could also fail if entry had got corrupted - should never happen, of course - and shmem then get stuck in a repeating -EEXIST loop. Maybe I'll want to do better for that case too, but not this time.) Hugh