From patchwork Fri Jun 7 04:55:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 13689247 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1F98C27C53 for ; Fri, 7 Jun 2024 04:55:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2862D6B0092; Fri, 7 Jun 2024 00:55:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2341E6B0095; Fri, 7 Jun 2024 00:55:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0D50C6B0098; Fri, 7 Jun 2024 00:55:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E33106B0092 for ; Fri, 7 Jun 2024 00:55:22 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 50539C0EE1 for ; Fri, 7 Jun 2024 04:55:22 +0000 (UTC) X-FDA: 82202878884.18.A4E2885 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf18.hostedemail.com (Postfix) with ESMTP id 85E001C0013 for ; Fri, 7 Jun 2024 04:55:19 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=3HCKw+yz; spf=pass (imf18.hostedemail.com: domain of 3tpJiZgoKCJ8XNRQX9GLDCFNNFKD.BNLKHMTW-LLJU9BJ.NQF@flex--yosryahmed.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3tpJiZgoKCJ8XNRQX9GLDCFNNFKD.BNLKHMTW-LLJU9BJ.NQF@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717736119; a=rsa-sha256; cv=none; b=BoMo8638z+ht8uP5o+tKAbEoWQnkewdEMvAPYxIE+13Kgc07ctXIbr8CGDTB7bdyVYwZQB ID89Y2NL0QP5MiiMxiUdnDs0nstEobRAWk0DmZoUeH+YuXIx+xkqdHox3s9iWqWsTtsY54 rq2JYqdWkLVE/psZzzCIAukxijXfGbM= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=3HCKw+yz; spf=pass (imf18.hostedemail.com: domain of 3tpJiZgoKCJ8XNRQX9GLDCFNNFKD.BNLKHMTW-LLJU9BJ.NQF@flex--yosryahmed.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3tpJiZgoKCJ8XNRQX9GLDCFNNFKD.BNLKHMTW-LLJU9BJ.NQF@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717736119; h=from:from:sender: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:in-reply-to: references:dkim-signature; bh=OYdwPhyhNa9Izr7t6fCsRMDARDJ3D6wcaG4TenaGYA8=; b=hRWOkR3BuMf5zk60wgeyUVxA3ZVd26s34DZ1gxR6tvdyjuOihMHT2LtCivH0G5Is9FJ0xS KkHjGx/Tpz96FANjgVDl0uWDqHkPAx1GMEsc0v0GYIFC7kUG2aIXvH6i86hQLMn+1rH21x VQFKDn7w3RkrGuFMBLi+rG0w3VTfmbA= Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-df78acd5bbbso2911875276.1 for ; Thu, 06 Jun 2024 21:55:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1717736118; x=1718340918; darn=kvack.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=OYdwPhyhNa9Izr7t6fCsRMDARDJ3D6wcaG4TenaGYA8=; b=3HCKw+yznkhZpG/rQ1ccciAQoHoK/z21x/8dT/RZW5Q/8WCSR7hv5g67/TueL4J9sN 3pYrsODk5URUMe0yGjbVVeuyEuvgqogsS44Qr2+K7CGBlCZqc89lq9ONKcB4Tj6+vjKT XvqP2Ny9pGkP8Y5RYwrZwhjmhpnCwBrl2sejydIAJsyi6tRNiOZ4DoGcr4lPL36VDHo7 uULF/kcIc33WHw1ahTCPkqtxFrr4lFb4Lk7xNvXFob0fen+WXEbi0m5PZB9HTlu4AEgU fxbc2c25mvhzVcwo+hh18t1UlmRzZBDDCurv9Ae9NGnw6eHV+Y5VxHs4gKL4Z9ASQ7W7 YArA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717736118; x=1718340918; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=OYdwPhyhNa9Izr7t6fCsRMDARDJ3D6wcaG4TenaGYA8=; b=RDQpSyd3P8albY0AhJMxoq87bh8MCsc6UMZw+7mnWR1PqHiNdfzTGsqglNBrWav71m dy0apmaTx3yswgNdemJGlfohJdaXXmMeHYY+DdcYXgJZvKYzrw5etmQBKu/rFue/1+f4 qb5g27iphhBHNMfq1yaUK9yUPpLv3OHsb28BeXAGIaAK1H2yLDP7Fl6/6kSVybGbJwht wrwFSeRkr6P/2omD8bsNBsaWqLq33lDxzrQZijEaWLYyKzWp9tqbZnNunaO47ursyYr5 MqM/y4o9i3Ci87OGDzYEUB2eFm+Tj1OFGAzWnHyq7FE+kmWKpZ0sQFnHrNgLgK4MBIXW pMkw== X-Forwarded-Encrypted: i=1; AJvYcCXXbfyqHXF2wZMPAz+idToIoOGP5+gTJ5Bb4UKN4Sldn5yBnsN3Sw0xu7/ZqDn/vkZakUMiOq2A/ueU3T7wB8m1hlM= X-Gm-Message-State: AOJu0YwQNcfZghbBQIu9B8KJ3+NL8FB9+WZOusKtfrAXUljS/yeob54w blW7M4IkD1inISdUpNMIGl8qbjdM2zpzRqQirfhkgqgEYZZODlj6qx+2hczR0ej9khJc/B+I/9M uERUt0GPmCh3E7On7Ow== X-Google-Smtp-Source: AGHT+IEv8nz+gxYGrnMhEiKFDXTsWv1jFxyEGs9paC12YqiVNJpvm1ANOW3vTT96ligvd/cwGEcbnl6Mw4T8vX+O X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:29b4]) (user=yosryahmed job=sendgmr) by 2002:a25:f607:0:b0:df1:d00c:130c with SMTP id 3f1490d57ef6-dfaf64eee07mr70778276.5.1717736118238; Thu, 06 Jun 2024 21:55:18 -0700 (PDT) Date: Fri, 7 Jun 2024 04:55:15 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.45.2.505.gda0bf45e8d-goog Message-ID: <20240607045515.1836558-1-yosryahmed@google.com> Subject: [PATCH v2] mm: swap: remove 'synchronous' argument to swap_read_folio() From: Yosry Ahmed To: Andrew Morton Cc: Huang Ying , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yosry Ahmed X-Rspamd-Queue-Id: 85E001C0013 X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: e54hq9u4bc8dix8cqeffubnmxo8xq9oi X-HE-Tag: 1717736119-569885 X-HE-Meta: U2FsdGVkX1+AxgUqjH8zi3iTTElJGy69fWDlimALmcguvuEln/co95fDf6jgLx1o5aMsj4Wxxb2HfYvedmLo9E0NR0QCB18L8PPEOO4rtfB3ioTNmHshieH/M8WOIqhw0VBTdJzbiK5mYCENoSfOOKh+J9A+G+qWY7tBvI/XIYRv49N6fwDtipz5m/fnZnYkL1zL4wEonyEj0mO+0pp9wmawklXjeUD8pnZwGJn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B3WmfDzh20Xd73fYnBTVsuDq0ArqhsCCbTMsNMye18O8Yr0j9RyAyRRR5TGQH+CE/s7IXgt1emjqYDHUNzo5JIMXJqt2Qag5C2kpwJ7CTVvZ/8fjjg8HvYuZito5vqbs73YgVj3A8viW2LNJEkqnTPArHCRgCSih0tIEGwew/S9MgLtyf59zapc6OhLtecHtL8IGJoMJTjCwf7QRTF6QyHMbmUsH886KGs6Jc6FIW57MijtC8JZjZrW+wfF/AeKaAKdjhdWk7Tqtc3QBoOtuwxT143V7FeQHeRP3IClzCZJuYrzDLBPKIhu6v7L6M3I4iF1KEp62sP3TBlfgYp+0aiDX0B7CZhaozNoseH5g2vfqjijucFFP9EMWrUPWsJTg= 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: List-Subscribe: List-Unsubscribe: Commit [1] introduced IO polling support duding swapin to reduce swap read latency for block devices that can be polled. However later commit [2] removed polling support. Commit [3] removed the remnants of polling support from read_swap_cache_async() and __read_swap_cache_async(). However, it left behind some remnants in swap_read_folio(), the 'synchronous' argument. swap_read_folio() reads the folio synchronously if synchronous=true or if SWP_SYNCHRONOUS_IO is set in swap_info_struct. The only caller that passes synchronous=true is in do_swap_page() in the SWP_SYNCHRONOUS_IO case. Hence, the argument is redundant, it is only set to true when the swap read would have been synchronous anyway. Remove it. [1] Commit 23955622ff8d ("swap: add block io poll in swapin path") [2] Commit 9650b453a3d4 ("block: ignore RWF_HIPRI hint for sync dio") [3] Commit b243dcbf2f13 ("swap: remove remnants of polling from read_swap_cache_async") Reviewed-by: "Huang, Ying" Signed-off-by: Yosry Ahmed Reviewed-by: Christoph Hellwig --- v1 -> v2: - Collected Reviewed-by (Thanks Ying!). - Added some historical context in the commit log (Ying). --- mm/memory.c | 2 +- mm/page_io.c | 6 +++--- mm/swap.h | 6 ++---- mm/swap_state.c | 10 +++++----- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index db91304882312..2b3ef08e8bb7d 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4113,7 +4113,7 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) /* To provide entry to swap_read_folio() */ folio->swap = entry; - swap_read_folio(folio, true, NULL); + swap_read_folio(folio, NULL); folio->private = NULL; } } else { diff --git a/mm/page_io.c b/mm/page_io.c index 41e8d738c6d28..f1a9cfab6e748 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -493,10 +493,10 @@ static void swap_read_folio_bdev_async(struct folio *folio, submit_bio(bio); } -void swap_read_folio(struct folio *folio, bool synchronous, - struct swap_iocb **plug) +void swap_read_folio(struct folio *folio, struct swap_iocb **plug) { struct swap_info_struct *sis = swp_swap_info(folio->swap); + bool synchronous = sis->flags & SWP_SYNCHRONOUS_IO; bool workingset = folio_test_workingset(folio); unsigned long pflags; bool in_thrashing; @@ -521,7 +521,7 @@ void swap_read_folio(struct folio *folio, bool synchronous, folio_unlock(folio); } else if (data_race(sis->flags & SWP_FS_OPS)) { swap_read_folio_fs(folio, plug); - } else if (synchronous || (sis->flags & SWP_SYNCHRONOUS_IO)) { + } else if (synchronous) { swap_read_folio_bdev_sync(folio, sis); } else { swap_read_folio_bdev_async(folio, sis); diff --git a/mm/swap.h b/mm/swap.h index 2c0e96272d498..baa1fa946b347 100644 --- a/mm/swap.h +++ b/mm/swap.h @@ -11,8 +11,7 @@ struct mempolicy; /* linux/mm/page_io.c */ int sio_pool_init(void); struct swap_iocb; -void swap_read_folio(struct folio *folio, bool do_poll, - struct swap_iocb **plug); +void swap_read_folio(struct folio *folio, struct swap_iocb **plug); void __swap_read_unplug(struct swap_iocb *plug); static inline void swap_read_unplug(struct swap_iocb *plug) { @@ -83,8 +82,7 @@ static inline unsigned int folio_swap_flags(struct folio *folio) } #else /* CONFIG_SWAP */ struct swap_iocb; -static inline void swap_read_folio(struct folio *folio, bool do_poll, - struct swap_iocb **plug) +static inline void swap_read_folio(struct folio *folio, struct swap_iocb **plug) { } static inline void swap_write_unplug(struct swap_iocb *sio) diff --git a/mm/swap_state.c b/mm/swap_state.c index 0803eedeabe3d..994723cef8217 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -567,7 +567,7 @@ struct folio *read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask, mpol_cond_put(mpol); if (page_allocated) - swap_read_folio(folio, false, plug); + swap_read_folio(folio, plug); return folio; } @@ -684,7 +684,7 @@ struct folio *swap_cluster_readahead(swp_entry_t entry, gfp_t gfp_mask, if (!folio) continue; if (page_allocated) { - swap_read_folio(folio, false, &splug); + swap_read_folio(folio, &splug); if (offset != entry_offset) { folio_set_readahead(folio); count_vm_event(SWAP_RA); @@ -701,7 +701,7 @@ struct folio *swap_cluster_readahead(swp_entry_t entry, gfp_t gfp_mask, &page_allocated, false); if (unlikely(page_allocated)) { zswap_folio_swapin(folio); - swap_read_folio(folio, false, NULL); + swap_read_folio(folio, NULL); } return folio; } @@ -834,7 +834,7 @@ static struct folio *swap_vma_readahead(swp_entry_t targ_entry, gfp_t gfp_mask, if (!folio) continue; if (page_allocated) { - swap_read_folio(folio, false, &splug); + swap_read_folio(folio, &splug); if (addr != vmf->address) { folio_set_readahead(folio); count_vm_event(SWAP_RA); @@ -853,7 +853,7 @@ static struct folio *swap_vma_readahead(swp_entry_t targ_entry, gfp_t gfp_mask, &page_allocated, false); if (unlikely(page_allocated)) { zswap_folio_swapin(folio); - swap_read_folio(folio, false, NULL); + swap_read_folio(folio, NULL); } return folio; }