Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp990295iob; Fri, 13 May 2022 18:48:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyw3jJjhRURjNaclBBImwr2j0+EIK6eW0dVadhQXJ553g1T4CEKCeRCDh5LrEXKaiJZriD1 X-Received: by 2002:a05:600c:1906:b0:394:5365:6720 with SMTP id j6-20020a05600c190600b0039453656720mr17366504wmq.102.1652492918262; Fri, 13 May 2022 18:48:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652492918; cv=none; d=google.com; s=arc-20160816; b=B0W53bu9kGvQ16jPtgQ9p4RJiIq/LGIJMSREqpa6gY/ee4g/ohQK6vFFCm+eL6Nbyk aQkA0ElV/pnZHhcUpISQwMvREbljJpaYi7nE9Jsvr01Eq5SlNsYE0X/sr8LYRIdGuJjY sD9yRTw+UQ1gMGdR1SuLbzC7F+4ZCUAnxqbHs1x/T3ttl+0YtnRssUp6bxZdWu/lBMVv m32eBhgiCXd7jaZvvxhu2t7kqkO8uaOaVW2e05WzTAjE0iz3t6HU6Ee6z/DowQCL5dav Z0MuGfP947R2IItaqF3PH4pG6S+Me3bFIFX8j9HmIeP0eq85C9rP+gh+7eHczxDZwzUw Ye/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=CXmdhmeZNjqxLqkQ0Z6PawE3Kif9Q/4jnU0D4GWa8iQ=; b=d0ITmS857CVuWYKDbfOqdL+nu7AuZhKQlsz8R3VXCev4x1Fp4Q/rWjILyJODs1z74f hyp3qWQ1JBoE3Z68gAjtwPnBUmmsv2DZt6EseN3k2xNMXcpydikb0bE6XdHBX2L0J71p A6IT1cd4t5wX4LxgQza5FykbuDTzkJHaHxfqMya+ToFmP1zoEcrdeHU1K3pT9ypoLH3v FHvgRt3tFEf9gvvfz50dnCu9bb/GoPa6HtsRbM7wF6jaWDBThl0ar+16VhmfQmo1WEjJ m/x11ktYEchovnjyWAHQqhn+2hSjYZzeKarXXSS12OeZE3iQ9Jy9MnW8CBAUk6Qd+5V9 XbgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XCsxT8EH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j12-20020adfea4c000000b0020c622c0618si3368816wrn.322.2022.05.13.18.48.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 18:48:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XCsxT8EH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5F79131D1B4; Fri, 13 May 2022 17:12:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354356AbiELNhi (ORCPT + 99 others); Thu, 12 May 2022 09:37:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354353AbiELNhh (ORCPT ); Thu, 12 May 2022 09:37:37 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9C2CBE0D0 for ; Thu, 12 May 2022 06:37:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652362655; h=from:from: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=CXmdhmeZNjqxLqkQ0Z6PawE3Kif9Q/4jnU0D4GWa8iQ=; b=XCsxT8EHoJ6xFUl4i6BgIcmQCTbqRVdlwEx/J9mKW6Le4PVFvT2NaJvxxuH3JwbkaRSD6Z Asko+apYghlTJnQUyut56Um6SNQh2Fp39lHLUfE454CWlrhoZU19/vMg/tO5jaHAWQg3N0 GuY8sfS6s+MqFBGiFCpWPxlaJJs+VFE= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-633-ZP223mQ2O66K8FOcCXpAew-1; Thu, 12 May 2022 09:37:19 -0400 X-MC-Unique: ZP223mQ2O66K8FOcCXpAew-1 Received: by mail-wr1-f71.google.com with SMTP id ba21-20020a0560001c1500b0020ca6a45dfcso2079131wrb.9 for ; Thu, 12 May 2022 06:37:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=CXmdhmeZNjqxLqkQ0Z6PawE3Kif9Q/4jnU0D4GWa8iQ=; b=vEyustr9aRfHlY4T/og8fedWAo0hwV8N+Do5hlBPQj7ifKbPXvKNjZFzyC65UFHIfu 1T/qdsDKefi41ylY/pKHZLABA1T56G0ymiaZYns5wn0DWcE7PwgBzUhuLIMTwzSID5F6 x5WOlzehrTZpY5oQ5ecNy8iALDbKoLJLixji2sQDWG/RII2/p0N0jXMgeI+HRLw3PlvP ZFnxSA6OahOXCcKhQOuLqUN/dfNSlaK0gvLqJc97xuGF6iyuodlWjzV0zZkEYC4SU4Xf ewURCFfQKLO9aXLYH4b7KB7y3WlAUw2lbcAgzUP91yNGCaV5N1rS7LJt+caVPyBT7SKj U49A== X-Gm-Message-State: AOAM532/rdAj/H1FqtBaNxTL2zBbNjTWxXs4U8G1ltySpXrViTbbYrYx n8N4YT23J4jWCyAr8rfW+bRp7pVRscZxkVervnG12Ich4Pc2xnY+insmc/Nw81Nlwg8CKZ0bANm 54PyUrzcKYVV2TRz2j9dFV3mo X-Received: by 2002:a05:600c:3b9d:b0:394:70a0:12d2 with SMTP id n29-20020a05600c3b9d00b0039470a012d2mr10422244wms.64.1652362638561; Thu, 12 May 2022 06:37:18 -0700 (PDT) X-Received: by 2002:a05:600c:3b9d:b0:394:70a0:12d2 with SMTP id n29-20020a05600c3b9d00b0039470a012d2mr10422216wms.64.1652362638308; Thu, 12 May 2022 06:37:18 -0700 (PDT) Received: from ?IPV6:2003:cb:c701:d200:ee5d:1275:f171:136d? (p200300cbc701d200ee5d1275f171136d.dip0.t-ipconnect.de. [2003:cb:c701:d200:ee5d:1275:f171:136d]) by smtp.gmail.com with ESMTPSA id v16-20020a7bcb50000000b003942a244ee0sm2549625wmj.37.2022.05.12.06.37.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 12 May 2022 06:37:16 -0700 (PDT) Message-ID: Date: Thu, 12 May 2022 15:37:13 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH 06/15] mm/swap: remove buggy cache->nr check in refill_swap_slots_cache Content-Language: en-US To: Miaohe Lin , akpm@linux-foundation.org Cc: willy@infradead.org, vbabka@suse.cz, dhowells@redhat.com, neilb@suse.de, apopple@nvidia.com, surenb@google.com, peterx@redhat.com, naoya.horiguchi@nec.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20220509131416.17553-1-linmiaohe@huawei.com> <20220509131416.17553-7-linmiaohe@huawei.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20220509131416.17553-7-linmiaohe@huawei.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09.05.22 15:14, Miaohe Lin wrote: > refill_swap_slots_cache is always called when cache->nr is 0. And if > cache->nr != 0, we should return cache->nr instead of 0. So remove > such buggy and confusing check. Not sure about the "cache->nr != 0, we should return cache->nr instead of 0" part, I'd just drop that from the patch description. We'd actually end up overwriting cache->nr after your change, which doesn't sound right and also different to what you describe here. > > Signed-off-by: Miaohe Lin > --- > mm/swap_slots.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/swap_slots.c b/mm/swap_slots.c > index 2f877e6f87d7..2a65a89b5b4d 100644 > --- a/mm/swap_slots.c > +++ b/mm/swap_slots.c > @@ -258,7 +258,7 @@ void enable_swap_slots_cache(void) > /* called with swap slot cache's alloc lock held */ > static int refill_swap_slots_cache(struct swap_slots_cache *cache) > { > - if (!use_swap_slot_cache || cache->nr) > + if (!use_swap_slot_cache) > return 0; > > cache->cur = 0; I feel like if this function would be called with cache->nr, it would be a BUG. So I'm fine with removing it, but we could also think about turning it into some sort of WARN/BG to make it clearer that this is unexpected. Anyhow, Acked-by: David Hildenbrand -- Thanks, David / dhildenb