Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp1822887rdb; Sun, 19 Nov 2023 11:51:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IH/FnpaltSJN1qIAyaCPiQitsLfJPU2h48/ZSN1Z+44Mi896UCoZTN6cg6k46OiW9BhNpM+ X-Received: by 2002:a05:6358:1812:b0:16d:be8f:fe6 with SMTP id u18-20020a056358181200b0016dbe8f0fe6mr5067123rwm.30.1700423515978; Sun, 19 Nov 2023 11:51:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700423515; cv=none; d=google.com; s=arc-20160816; b=jctkVv/Pda99Y2Rc4RnqDv//nhAjtT0K9tIX0u7QknZpyx4L5y1RGVjlAjvpMNIeuk NNXZwzGDsIBdFoO6B9YciPa/34cx7f7BgXsZhmMk2ndKmUdS7piTKbNVvUTSwF5QBYNi NyD3UTwT7kMkTfyV1AVTx8kejvW5AMQv8fxdme5JQlXPa7E+NUkIupnTgBtRmEbK4sq4 Nd8d6MzyBkWk6rzO6zMtWPTBEX/ZhZsvBJMHzQgMJ1Y42WNMKez4cXLYNm2kBvbeKI/c yzJe/DngeCNoZH2XZZFOyFvkNFZoxFDPy65wvGmcV5HtcsSdzxUigxiosvNkym2inRpJ oOOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:reply-to :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5hBTip8l+rVWgXZvgeAFfyX4NMH7GqXDBsHUYVWi3uA=; fh=4HE/piJoUCKuBTCCBiej4//zvvzywHdOLL9QM/KYjYM=; b=mQ8n8x6ipqYYoXk4g2yyaHjPphbAPpFLbENqr0Bwiyq2abz8zyJjJ0dLbqbepCZlvO P0fTLUoivG3658R3YqRHgyJc9xwP4bxNSou5mGmUpic44z9ObD7FFFDP2ArXozTaFCk0 P3aVFiCcbRCYiwVXyJELMfF8LueQ4sw0OC5mK+BEHrueLEaBVyYshCwhxQL0lppj3QCQ oEFNIy0AWpmtK7o1jHdnMq3cCibjG9xqWeNnaAJt0txF+I8HVEBCSbgSToubpjvBXQwE 5ayK6NAROorbZV6Uq2PCenZteabZ1bOd/9HEdTLdgbkVD6vdp4CnNTQ/kw/Zi9XQJSys iUXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=UtyXFX0e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id f19-20020a63dc53000000b005bd052042f4si6673950pgj.69.2023.11.19.11.51.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 11:51:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=UtyXFX0e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id D074D805F875; Sun, 19 Nov 2023 11:51:18 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231788AbjKSTt1 (ORCPT + 99 others); Sun, 19 Nov 2023 14:49:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231661AbjKSTtJ (ORCPT ); Sun, 19 Nov 2023 14:49:09 -0500 Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B842CD49 for ; Sun, 19 Nov 2023 11:48:44 -0800 (PST) Received: by mail-oi1-x231.google.com with SMTP id 5614622812f47-3b2ec5ee2e4so2610802b6e.3 for ; Sun, 19 Nov 2023 11:48:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700423324; x=1701028124; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=5hBTip8l+rVWgXZvgeAFfyX4NMH7GqXDBsHUYVWi3uA=; b=UtyXFX0e8/Ek/UERAhjAlWMzQLzTdg1YsOffvyqWYEG5x7xqYEA9coS/BQHM1Cx7ZG tI/6PmGbi7sUpz5Tq/0QuBh3z0CILn4eD0vrPpcNx2tgfkp1qPipIaWVSPUzQThbLdwN jlhbGQlKII2fg4nKvDsIkcqqfXIOQhJJFHgqSqIaJYIMQVNe6xzCdwWD79+/3KnFxkIN TcDMpUvQHTpDKP4f4GyW630CuWVXw9BO1jMVQajqB0yb+YsXe7WCcRiA0qK1de1MJyg+ jkyaB/0+PCZ0ulxvictw8dWMjgSQP2EgMZVMsJwgvOz/9nsdzaal7u+BNGcF6iepH6LW GH3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700423324; x=1701028124; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=5hBTip8l+rVWgXZvgeAFfyX4NMH7GqXDBsHUYVWi3uA=; b=IocGKSInJPDQxeJAX74SOzPcR/aQYuKSLAwpo10JZhbIWYBsws+Ga83ReVt0EGQtiu +LMju/kXgzw0xd/EVtP+/ExMt5HugZddezpE1JCTS4W5HbGjDC53m+Zna75FrUBhCM3+ Z7mBJU203kScmNGpY8x2ZDEQKiK/LN8Z+0TS6oAmmhNrRN/Ld96yCXEoPQmfC8hcxCuT 5b4C2bguz/LRuWkYXSUoU+RQZbPKTtiqHUCy38qWGjpvT25FSdot6GMZpSjeLzXYAmz2 q2KE9Q/iZZED7lspvd3TFSwdZR6tdD0fSxPNT2ITQcAmUVSk0/ryCF3mS2JXoJXULVcY JbDA== X-Gm-Message-State: AOJu0Yzm8pgyUo1gRv9vKc/yrbniJtnpP7BTnHktKfsqhIY4c2ZhVQeE bTU+SJidFmF4h7wdXQui5aw= X-Received: by 2002:a05:6808:3a10:b0:3ae:bae2:fa76 with SMTP id gr16-20020a0568083a1000b003aebae2fa76mr10473632oib.36.1700423323924; Sun, 19 Nov 2023 11:48:43 -0800 (PST) Received: from KASONG-MB2.tencent.com ([115.171.40.79]) by smtp.gmail.com with ESMTPSA id a6-20020aa78646000000b006cb7feae74fsm1237140pfo.164.2023.11.19.11.48.40 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 19 Nov 2023 11:48:43 -0800 (PST) From: Kairui Song To: linux-mm@kvack.org Cc: Andrew Morton , "Huang, Ying" , David Hildenbrand , Hugh Dickins , Johannes Weiner , Matthew Wilcox , Michal Hocko , linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH 13/24] swap: simplify swap_cache_get_folio Date: Mon, 20 Nov 2023 03:47:29 +0800 Message-ID: <20231119194740.94101-14-ryncsn@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231119194740.94101-1-ryncsn@gmail.com> References: <20231119194740.94101-1-ryncsn@gmail.com> Reply-To: Kairui Song MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,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 agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sun, 19 Nov 2023 11:51:19 -0800 (PST) From: Kairui Song Rearrange the if statement, reduce the code indent, no feature change. Signed-off-by: Kairui Song --- mm/swap_state.c | 58 ++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/mm/swap_state.c b/mm/swap_state.c index 91461e26a8cc..3b5a34f47192 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -336,41 +336,39 @@ static inline bool swap_use_vma_readahead(struct swap_info_struct *si) */ struct folio *swap_cache_get_folio(swp_entry_t entry, struct vm_fault *vmf) { + bool vma_ra, readahead; struct folio *folio; folio = filemap_get_folio(swap_address_space(entry), swp_offset(entry)); - if (!IS_ERR(folio)) { - bool vma_ra = swap_use_vma_readahead(swp_swap_info(entry)); - bool readahead; + if (IS_ERR(folio)) + return NULL; - /* - * At the moment, we don't support PG_readahead for anon THP - * so let's bail out rather than confusing the readahead stat. - */ - if (unlikely(folio_test_large(folio))) - return folio; - - readahead = folio_test_clear_readahead(folio); - if (vmf && vma_ra) { - unsigned long ra_val; - int win, hits; - - ra_val = GET_SWAP_RA_VAL(vmf->vma); - win = SWAP_RA_WIN(ra_val); - hits = SWAP_RA_HITS(ra_val); - if (readahead) - hits = min_t(int, hits + 1, SWAP_RA_HITS_MAX); - atomic_long_set(&vmf->vma->swap_readahead_info, - SWAP_RA_VAL(vmf->address, win, hits)); - } + /* + * At the moment, we don't support PG_readahead for anon THP + * so let's bail out rather than confusing the readahead stat. + */ + if (unlikely(folio_test_large(folio))) + return folio; - if (readahead) { - count_vm_event(SWAP_RA_HIT); - if (!vmf || !vma_ra) - atomic_inc(&swapin_readahead_hits); - } - } else { - folio = NULL; + vma_ra = swap_use_vma_readahead(swp_swap_info(entry)); + readahead = folio_test_clear_readahead(folio); + if (vmf && vma_ra) { + unsigned long ra_val; + int win, hits; + + ra_val = GET_SWAP_RA_VAL(vmf->vma); + win = SWAP_RA_WIN(ra_val); + hits = SWAP_RA_HITS(ra_val); + if (readahead) + hits = min_t(int, hits + 1, SWAP_RA_HITS_MAX); + atomic_long_set(&vmf->vma->swap_readahead_info, + SWAP_RA_VAL(vmf->address, win, hits)); + } + + if (readahead) { + count_vm_event(SWAP_RA_HIT); + if (!vmf || !vma_ra) + atomic_inc(&swapin_readahead_hits); } return folio; -- 2.42.0