Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp2961895pxy; Tue, 3 Aug 2021 21:34:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+0HvKIWsjveuMiHv/xRFEdk7sRCLWwuZQlAjGQQijET+KZbWd4C6SHte0tiIl9Oa3/U5O X-Received: by 2002:a92:cdae:: with SMTP id g14mr1582578ild.123.1628051674851; Tue, 03 Aug 2021 21:34:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628051674; cv=none; d=google.com; s=arc-20160816; b=ukDsWgZecpOqjlfQa6DqbmrOz5HZvbtBat08zEBW1ARDodveg94EXVnLdjDJ8g3FP9 ju7GfiOOJXTynqV8wR6od1ORlEHotSH2DN0lscMulDuQFWThJB5bDdaLQZntvnKfYx+5 XwSiXWEXYp/nxFoUlMN09jWb+yOukIvN5cTAoJ0DW9KPtkX+paDOmeVmocpbffEf9EFg dJT63d7oXpG6QUtT4jl1k8BRHSpNNfzmV3xm06Jr1IM7PSkqlyFvhIzWrlodhNVmuY8K nqWKoJD4PHa2P42KgmkWlXF8UQ7xjEbn4rCtyUDuQQHnqR87xAVU1lI5OMlUPZox3npV kFvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=V7dlIRAth9sYvaZsn4KNNo84AomPSoot7o917Iory/g=; b=CeoKqB5aurYYa3AOP1d7s0buLhwxoWSkEpbNq8qZHPYZwPhx4DTgaGqMbKHSEiT7Sh lnhUkZY6AU2SPcDIU//HiJ7+nOiIpT4jtkrol0G15h9nsSeNb2r+kfBvpGMCmmzFybTQ qSXIBFCuTxcK5rdlosjgZySM7yTlZz5axxut36aR2SikjeKOu2/6isU0o9j8Q68h+ByR 98iAsh98xTkCrUocttKUgUk9YGXDyh+iglVFsvHeCbJl0b/Jx6pjUL8ERrH4PUTDlftv FYxdhrF+F2IBNtjw0G/TkqH/CCW838xmL98sksXot554cPIMa7ruC9YsooWoOV2sr8Ha k7LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=fdGDsSmc; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k15si1211859jad.51.2021.08.03.21.34.22; Tue, 03 Aug 2021 21:34:34 -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=@google.com header.s=20161025 header.b=fdGDsSmc; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232618AbhHDE2n (ORCPT + 99 others); Wed, 4 Aug 2021 00:28:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229562AbhHDE2m (ORCPT ); Wed, 4 Aug 2021 00:28:42 -0400 Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED6B1C0613D5 for ; Tue, 3 Aug 2021 21:28:29 -0700 (PDT) Received: by mail-ot1-x32f.google.com with SMTP id e13-20020a056830200db02904f06fa2790cso587368otp.1 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=CYbLviw2vWDfAqdQmo862DW0CvBlzcgJ+ETvxYg6mdr/JfvQR0vzgJO23GbpUVTDtw m4zCZB+bOe5Rma8PkI+VJ7KYZG5lbYXzz7jGyLl42WCqFr9D8PnUSlqVH3rCkkmBaPEx Fk/DpJPdxZjQcyksSdB+glLcHmlDhEfRJKAUX7usyMQdiL5qBBbStz2/glUPQhfVSPP8 TeWSQ2o6KjZdsazrGux2m6SkUeRqQ9Sm5LLdbqmpk+I+ZYnzWoYeqEThmGu01j+unfVV YwLzJ5kOh5PY+/DXsr8N/9ebyaT+5/RWq8+zTL84IgOAwTE0lt/5m2KO/9o6/jB9XVko 3oGA== X-Gm-Message-State: AOAM531C8cKms9Q3X3yNPh4GnU0Vb/0TlSkqr+HxA81nrJ0QQKjynAid hP75X/8RQwHqsKOnnYKyQltfUA== 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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