From patchwork Mon Jul 10 22:16:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minchan Kim X-Patchwork-Id: 13307695 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 D7DCBEB64DA for ; Mon, 10 Jul 2023 22:17:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 278048D0003; Mon, 10 Jul 2023 18:17:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 228A18D0001; Mon, 10 Jul 2023 18:17:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 02EAC8D0003; Mon, 10 Jul 2023 18:17:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id E819A8D0001 for ; Mon, 10 Jul 2023 18:17:08 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id B37191C7CDB for ; Mon, 10 Jul 2023 22:17:08 +0000 (UTC) X-FDA: 80997113736.20.57BE336 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by imf09.hostedemail.com (Postfix) with ESMTP id CC6BC14000C for ; Mon, 10 Jul 2023 22:17:06 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=cK5H4JTE; spf=pass (imf09.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.214.169 as permitted sender) smtp.mailfrom=minchan.kim@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689027426; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=iX+XeeQBJ9VBOVdfKbLK6LIAPaiWzzuOuh/zksCgLrY=; b=KF2C8V1das9Y9lrqX6VgTFCuIh/kCUnVgkauhnclYCe0FXYXmo4u2nzzl19jdBsgyt2APu HG5ttpACyS2zXhV6s5YqheXURn1cdfbzgKtYuGlW/qmX4NZELPuSb5YXwgq5aQbvX83Twq xAaNTLlYmnl+pgLQa8wE+LbQhfSHsX8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689027426; a=rsa-sha256; cv=none; b=UDVeebsWYRJaWcdX7mBBO3lPkyV6RCil/ttGN1zVqtCzMGDmDF0Ix+4DAoU65vsf6vEfWj sXdTi0iiBfkFftCov5ZfChsXkWepiFeh0tppUETGgDZLSCqCEvQUeCVSLKmps/YIsY6FJu 2HKuqGWqs/5VvCuVcujbX6j7LcIOqLk= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=cK5H4JTE; spf=pass (imf09.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.214.169 as permitted sender) smtp.mailfrom=minchan.kim@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1b895a06484so24690205ad.1 for ; Mon, 10 Jul 2023 15:17:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689027426; x=1691619426; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=iX+XeeQBJ9VBOVdfKbLK6LIAPaiWzzuOuh/zksCgLrY=; b=cK5H4JTEUSAeh2t/1frJ4CuEKgdXC02PmU4wEVtkxxosBObgrYyj8vWTI9Vy5EXtwJ U5cvFX6XwYLZnQw9azRNOyIdDmPonGM+mo6jlvn0hcXO9Yl8asDAmRVSZ/fx8MxMIv3m jYfXxLeytPttslqPeK2vX7sjkIngMgl1mNrY3iFzYUPb5wBUqi04kLEYDncE8nknJ+lT iCypiuU7lJKKz2pEcvTh4I5BdPbKbolzfaM5ZjPOJX0O+Jy6O4hk9gNyUtwrp2NSCYQW ZLfzg9kghFAPHKUh6CdX3H3x3WA4zfSkd0/qRqrMaJ6rchefPojvkXI6LQ6aiEUpR1cw R65Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689027426; x=1691619426; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=iX+XeeQBJ9VBOVdfKbLK6LIAPaiWzzuOuh/zksCgLrY=; b=KQ8yToRPAXm/Rt1Za1mdGeIy0enBrTupG+4xunRMPMkg+JWDh9k1JxwLL23RrHXq0P ZwLZGinAB2PmNtpl7lxuhzRze560ebH5RYmod3SgCgVCSgFZk4EO9x4YbcYTtMhxhVHL aLk77KMboem7hXVs7sZ5flC082ctajJ7xvUNN7Jo17OV9raTOV31qKBexjGHslyUvDS7 l/vYj35Y0kamS3cU0mGZTfSUsJzQzGgRLKLiV6Z2Xfjt144UM2MuvrLJuW/K6oFIRay8 NzVOmYh/f/Na8mMBM8hNqKRjDIdjtOVYAJ9Su5C047b1cvNODPMXDHsH+imnp8g6x/HW sN0w== X-Gm-Message-State: ABy/qLZnsgiyBvIWVoN+Qb3v0I5ktryVEPRqEgzHVsMJy2g6EPKDJvyC dnoR3hfe7VUOSptXvYxeebE= X-Google-Smtp-Source: APBJJlGtXAGqbJAXuodohquPN3aOCtiyuGR6UF9maBbNtb1vpvfH3r+x/2e9/+N0bnap/+UNoeybVA== X-Received: by 2002:a17:902:e5c1:b0:1b6:4bbd:c3a3 with SMTP id u1-20020a170902e5c100b001b64bbdc3a3mr13262326plf.52.1689027425676; Mon, 10 Jul 2023 15:17:05 -0700 (PDT) Received: from bbox-1.mtv.corp.google.com ([2620:15c:211:201:1922:28f0:ba3b:368e]) by smtp.gmail.com with ESMTPSA id c23-20020a170902cb1700b001b9bebbc621sm376425ply.136.2023.07.10.15.17.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 15:17:05 -0700 (PDT) From: Minchan Kim To: Andrew Morton Cc: linux-mm , Jens Axboe , Konrad Rzeszutek Wilk , Seth Jennings , Sergey Senozhatsky , Minchan Kim Subject: [PATCH 1/3] frontswap: support backing_dev Date: Mon, 10 Jul 2023 15:16:57 -0700 Message-ID: <20230710221659.2473460-2-minchan@kernel.org> X-Mailer: git-send-email 2.41.0.255.g8b1d071c50-goog In-Reply-To: <20230710221659.2473460-1-minchan@kernel.org> References: <20230710221659.2473460-1-minchan@kernel.org> MIME-Version: 1.0 X-Stat-Signature: yur7duo1zqqhc971tyqprd1ucu3gf764 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: CC6BC14000C X-Rspam-User: X-HE-Tag: 1689027426-211772 X-HE-Meta: U2FsdGVkX1+ubqpXP9O//FxnEVIiFO2hdbKv21J6QOtpPQlxGPhvNgAwcPHQDeKbVrvOxtPC/HcZme6rY4ZYj+J01chyPuboQePNJMikzsfw23PmsWtMo+Ul24sscIk66/tUkTcuXlFo6Xq/JXZfvOEbEWd/yl4PpceQfTjFugGOQmlUK7mHRu1DS4XdnomzWCI7FsyCw22qZBXffykgGmjMWCEuKTHSNTXfhdUS+drBvRLirhIvJIt4TIj+RiNVqyjvtZ9C6tM1Ov3DASvJnpmIaV8aPzU/5pk8lkCBmapyWIqPVK0dhsEuxrQgSd0kjQcajPIwHENmRCRdS3ymTENUvVC95LYXSPxkk0GwdMqagwpz++9AdZdiAySJnDGBVivkVYb/NNg+tyfnev5AEHRDC07sumaAmhMFI5EJG98FWFhwFPi6r8B5Oqd72jbu1Or3lcRIrJiD70wW1N9wtOj6ekjCkJhciF8Ibwb28KSjx8K6K5oMooUrTav8XcJ3ciyg4cBdvgkrh2H3KrurMuQMyrvwwLulDgt6ic9owBUjAov1QQv7FGJUe0euL3GrlY0UHHFlmpS0IiMtAXLLO0sUGFLtr4CC+3/pdrZgqXhNzvHvCu1h72BhpoLWOFF6qj4Syrdk+Ts319AzPD6B+xxx70gGef2HPNVwo4Ox52fnlkrC/0B1TgjdDusrVJIuZwnH5V4N/wU47zP8T9iSaDKONGiVJoAvIjtJoYlNnkM9z+JdFVc56iE7DNOpTzZlSlqi7TujwGOPMZ3Q+aez6aETlNs4PkSpnBJJpEOQS5/8G7utKEJhnmyJzkZhGqrvMxcK2qN5pPQyNY/E6vxHOEjm0mEMsD8/JFFWWuC/5gFpw1K4K2QgWCAuKeFRV9ib6G+lxkdrkr20pGz39eUBH8o69/3sGZ5WE5qy6G2NZeoWZGiCLYnKGrDe4pOatm5mjoAnW6V4TVL8bZMgGDO x/4fTbNT i12OSSz6FutZlOrVFpcVQ7fRKlNyhLT7KbrglKMichNl7VdxJTTBh69fR5Q5j/s4+j1TLgKaaro5cOELJ4UbwEJ1r7GZYYXMB8Kmttv+DuCDD2tBZ9X8EwuxAlqZLsiq2NB+y+Nfm5RVrtfTg+AXPlHMP0MgwqCNaGrl9ClRIGQxjAEzCbFThC4VpQDxrKDK47TKIr+16ojai10RLjCeypruO9WcvM3iM+ma7vEkHLiLvUoZd0ZjZETvGoDrX2cuPaKQPpIKAwplhD+9eoJgs4r/N53SOUB+GQZTePk5c6Vgt6TjBqTlU8UicbCE8MNflxN5tTrn6vKyLwpwfIohgEyewI7ODO6wmEUniG8IZLPw3O1c8Z1oGRHSTaUUQon3JOrCuD1G47wnfLMDhIQ+SlMWPsmXRd2Lm648N+OybeInCojmSx1Xzs30e8GrbAOo1QKWNd4FdpyYOOMvnAkdzPcE9wtZqHrF8aA3bk7Ga4Jw22IfvVlPrvtsxoIaeqbgpfiovUjujBASObWpRw8y88HZRaeSCcnqKX3TR/Gcw84c49N+DJJGoHtcaNoaofzjN6gPlexZGAL2/31fL+oT5Ze8V0yDkm3y7HQDspsL8Z/W5HMM8X4Pvcv5ikt+ATqQM3rgRa8qkJzJZ/JPoecvthkYqNTHxYVfc4Bq1wVYdN2w7ijL5iq4ue5YcdnuXaizFXMcx 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: Modify frontswap to be used as a block device driver for swap partitions. Signed-off-by: Minchan Kim --- include/linux/frontswap.h | 7 +++++-- mm/frontswap.c | 4 ++-- mm/swapfile.c | 3 ++- mm/zswap.c | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h index eaa0ac5f9003..466d617dc3c7 100644 --- a/include/linux/frontswap.h +++ b/include/linux/frontswap.h @@ -7,8 +7,10 @@ #include #include +struct block_device; + struct frontswap_ops { - void (*init)(unsigned); /* this swap type was just swapon'ed */ + void (*init)(unsigned, struct block_device *); /* this swap type was just swapon'ed */ int (*store)(unsigned, pgoff_t, struct page *); /* store a page */ int (*load)(unsigned, pgoff_t, struct page *, bool *); /* load a page */ void (*invalidate_page)(unsigned, pgoff_t); /* page no longer needed */ @@ -17,7 +19,8 @@ struct frontswap_ops { int frontswap_register_ops(const struct frontswap_ops *ops); -extern void frontswap_init(unsigned type, unsigned long *map); +extern void frontswap_init(unsigned type, unsigned long *map, + struct block_device *bdev); extern int __frontswap_store(struct page *page); extern int __frontswap_load(struct page *page); extern void __frontswap_invalidate_page(unsigned, pgoff_t); diff --git a/mm/frontswap.c b/mm/frontswap.c index 2fb5df3384b8..967ce610a1de 100644 --- a/mm/frontswap.c +++ b/mm/frontswap.c @@ -107,7 +107,7 @@ int frontswap_register_ops(const struct frontswap_ops *ops) /* * Called when a swap device is swapon'd. */ -void frontswap_init(unsigned type, unsigned long *map) +void frontswap_init(unsigned type, unsigned long *map, struct block_device *bdev) { struct swap_info_struct *sis = swap_info[type]; @@ -128,7 +128,7 @@ void frontswap_init(unsigned type, unsigned long *map) if (!frontswap_enabled()) return; - frontswap_ops->init(type); + frontswap_ops->init(type, bdev); } static bool __frontswap_test(struct swap_info_struct *sis, diff --git a/mm/swapfile.c b/mm/swapfile.c index a6945c2e0d03..a9424fd226bc 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -2339,7 +2339,8 @@ static void enable_swap_info(struct swap_info_struct *p, int prio, unsigned long *frontswap_map) { if (IS_ENABLED(CONFIG_FRONTSWAP)) - frontswap_init(p->type, frontswap_map); + frontswap_init(p->type, frontswap_map, p->bdev); + spin_lock(&swap_lock); spin_lock(&p->lock); setup_swap_info(p, prio, swap_map, cluster_info); diff --git a/mm/zswap.c b/mm/zswap.c index c122f042a49d..9247e3adc21f 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1510,7 +1510,7 @@ static void zswap_frontswap_invalidate_area(unsigned type) zswap_trees[type] = NULL; } -static void zswap_frontswap_init(unsigned type) +static void zswap_frontswap_init(unsigned type, struct block_device *bdev) { struct zswap_tree *tree; From patchwork Mon Jul 10 22:16:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minchan Kim X-Patchwork-Id: 13307696 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 B9DC3EB64DC for ; Mon, 10 Jul 2023 22:17:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 560568D0005; Mon, 10 Jul 2023 18:17:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E8928D0001; Mon, 10 Jul 2023 18:17:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 313D28D0005; Mon, 10 Jul 2023 18:17:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 220A48D0001 for ; Mon, 10 Jul 2023 18:17:11 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 8BF8DC0299 for ; Mon, 10 Jul 2023 22:17:10 +0000 (UTC) X-FDA: 80997113820.03.512F412 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by imf22.hostedemail.com (Postfix) with ESMTP id 1F02CC0011 for ; Mon, 10 Jul 2023 22:17:07 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=TMlHIwao; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=pass (imf22.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.214.181 as permitted sender) smtp.mailfrom=minchan.kim@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689027428; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=8sEk/KJTsk1SrESg8tiLSDNDP7ej4yGxTZP0FlmemOg=; b=dc+EjOKTsjewh+rgCpmxRPUqcpkqI/GXFpCSk4NFItYtrDHT2MNRT2NeHv3q81DUKcJjWh 375Sc4T+mq0HowAJXeY5LEFGlPIviycgwLA+pde/6hTnnIuqg2iMlKfPRz10FpeunEJucq NPvAm8c3Kg69q7jtEXOC7/1b9FBKIK0= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=TMlHIwao; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=pass (imf22.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.214.181 as permitted sender) smtp.mailfrom=minchan.kim@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689027428; a=rsa-sha256; cv=none; b=emgzQB0K3wy7zyY4eQYm6yuJBEFsiiYLJWqeklrEAjd6XM9Nswd2i3YqHJLHLZ1N75eF9B MD2MgaV3YfFQPkk2OogtT8//yVehvYniiI8C7zX8TgSFqtS322bItr8/QsXEDPALRe50FX vGwHYiBSJ5igT98jL1TOhqsn/QNrlf8= Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1b8ad356f03so32352665ad.1 for ; Mon, 10 Jul 2023 15:17:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689027427; x=1691619427; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=8sEk/KJTsk1SrESg8tiLSDNDP7ej4yGxTZP0FlmemOg=; b=TMlHIwaoW2MqvvQrb+GxBUD2jQf87Dxwhnffklm6HxTH+58pH/x5MITcX7ZszAJkJJ 4TktvHWuKZcPfXUj8r8OwkPLXzxUXKycOd2esMiVNcVuRBEECjuSdCNG+60BBvIJq1G2 fVwDLn3CXLYRJN81aJnZxB5Rxau7VT3Qi67a8Mfzp7Jb2Pp9R5EYfkeqnWZl8z+4hdZO 9/jrpCP92YDEh41Sko9USDY20FElxmGZi9PRjDOxm/MRy4qI272MjJCy9v2BWSAMrPJ8 gG9xDHCVyY6xzGncFjqiLaFGgwaPkoLZEIH88c0f1tYjQFAbrVN8ILJApBb2+v77/v8Y lciA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689027427; x=1691619427; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=8sEk/KJTsk1SrESg8tiLSDNDP7ej4yGxTZP0FlmemOg=; b=a5ScwS3vrR0++Qrfs390o/m9/kg5ppSNZn/ZvidpqlZi+P4rCbuPX4ar6rmNtp7UHE bFk8MhhBErj5lyrWTD5g2csQgs9705CMbFgB13TIil/b+QIaYDV3YSDb9UGlRkLk7iyv xE2tiw5GoOS/DnLrVGkaVGHQ+NLNdQN84TSWS+6JWkc7QebJ8FUpE46JT55DltkM5cYb Uj3kpMOsdRVS1VBg6SzOZX5jl8gL/jWX1YwzZ4xKNSBUDkdGYNZuJLcqX9roo95VqZMy jd5grbagb/Bm0lASoJC7iZBRmXivGxNh4OUgcD4nkd0TSdKgyDIYt5ALRrCzhrNYAuhB 9qDw== X-Gm-Message-State: ABy/qLbuozTpzPQjh7/RZP93RLtxpXXSvEMdTUbpWv8TBB/I+2nUrOkN 0jpQj0XX1zpizNn3qms4we4= X-Google-Smtp-Source: APBJJlE2PFoBOjwwWXH692IGmXgN5v+4mpYQ8RniZs75yUZ+ETbiOcAqYNP4ZOECpnggUuniEUz51A== X-Received: by 2002:a17:902:e852:b0:1b9:ea60:cd8a with SMTP id t18-20020a170902e85200b001b9ea60cd8amr1588226plg.50.1689027427391; Mon, 10 Jul 2023 15:17:07 -0700 (PDT) Received: from bbox-1.mtv.corp.google.com ([2620:15c:211:201:1922:28f0:ba3b:368e]) by smtp.gmail.com with ESMTPSA id c23-20020a170902cb1700b001b9bebbc621sm376425ply.136.2023.07.10.15.17.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 15:17:06 -0700 (PDT) From: Minchan Kim To: Andrew Morton Cc: linux-mm , Jens Axboe , Konrad Rzeszutek Wilk , Seth Jennings , Sergey Senozhatsky , Minchan Kim Subject: [PATCH 2/3] zram: support frontswap Date: Mon, 10 Jul 2023 15:16:58 -0700 Message-ID: <20230710221659.2473460-3-minchan@kernel.org> X-Mailer: git-send-email 2.41.0.255.g8b1d071c50-goog In-Reply-To: <20230710221659.2473460-1-minchan@kernel.org> References: <20230710221659.2473460-1-minchan@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 1F02CC0011 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: dxz4goxwebhfq51w73m4utd8q48j3fch X-HE-Tag: 1689027427-153961 X-HE-Meta: U2FsdGVkX1+BrvIJepSHJpsTdjUASRUCPs7OTRev1FfS6E48xAOURzImsU+tjErFFIrxYZ8MMNP7E/v4v7jtnzcUHsvTKi9l+iCLxBlMx8Ag+nNDzo3OJ2uAevv3W2focQj7CnajuGR5VPoVRQ5FtybCxjhigffsF5TZdUWiixrzRAaqGBIHmtiSJaIJ574Myo4u75GAqhxF727oH+uD68EkfcEL7UY3Z1eRBjE4XgHr9XzAaE4OBu8nDBEeHUbfHrjICDX1hPRhc9P9tBz69YvMa1sZpZrsM+0lWJhWxh35EnONvMkPHtn49zuXsD5Ox3oRqq22HF5lsmGohumwRSYpY4ng2cV8Z80BKEPNnNVg314cn8KQ4mqQ1MwLgnME2wq+rRpRTVgA7NQ0CPRzHKVenbjOcwd4wZfxj/Ue884zT9VXOSO0IsBYbQQDx68YuNAqmlG59OaCpmZOlalGaEZqQF++51AE0wkgQwbBQrTDK8lll3FUMs+Ts8plNVG1N4O/kvsK++ya/n/EGUyCvMTxIobEBI+JH2SRzmHF19MkQc3uKrfdrzoQOumt0jHomQAlsgQeQR/gHGDtwWxrrhVdKBTB0gATcTW0WY3q28XAmDa/ZjqSocKTH5NkMuObcSyDKoktVjoBGU817TNEsoXG9sElGu0/P8jGYCbbfGnkoogz92vY60SPdLL1RcQ6s7Hd4dFDlNSMrHamB0J+0Y27jQtABF8difGKpHBfkoUyZZO4NLyxuu2+/hAJ3vmLcfPAuUcc0fJzpWyqCptoilsVwOon4cVHJlf4ng7js/0YEFmhTl25g1CwBJp1aEl4/iwQ+I13Sx5lv/kvLMly6TvOAx8kQdiZJc0pK0np2hhoHerOWIF1d1AgXtkNeJ2v4j3wa4JgFtY1crB5TFWSV+NoKvzZEDm+pD7mr7+IK3rb+1yhcmYaVbZhJyeTx9br6IIYPsmJVXAf1BK+Rfn HFRiOSfs s2y2nrVcIFfGnNcleNhqVOIne3mo5LpV1KbQkJEcLZpVUjCXAhIIlKlw7WaQKx4OQkcxpzCeH3gv+b6MJzJ0v0Z4B9i40YvCcpE6uV0aYAfH7g+yysNO2BVmseVsgJiN6EcMm/VyuFK+3tKi5nyoLaXxijjG26bVmafYNbPAL6UGvStAXzZZoIAvFxArG5dlG57YROHxIFUMi28dKU7hUFt5CJT1eqzadOY3IWY+1rCKQIxikhHDdujzq6n0DKE4qzRxU13lvKAQpwOtGzZ2eAdCAY9yL9p/R/zcTnm+u22gAGAxK0bvefYrXIDfjVkj6cEoavnf5ymFqerytctXH+gnQAseBEJgMJbCVcEj9Q8/GzOZsF6/oUtZm5PTkwRJZTSH4HTIfsG2HNA52xOHjKH4G/7VZq4ovCj6u2LV1XOMSr6CozQ1BLgmvv29wo7E41DHvcONT3HTCz/QajO+omAoNiWGOkM/iDeWhWm9qEblp1cY3ezb0vw0Z4fpXJNDLuLqFGrJzNCIbGzuooLe9SINfN+OkNtBXc5Hwjvtg5hd/PnmOUcZ+3LQMtIHoF1otCFCLbEvbDUNUeRxWE7x2FS3MGRD2AGVSbZO9Bxi9H0L6r0omZ5sJA7OLnzdLQU4dErhZ8P/Lk3+tkFI= 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: With frontswap, zram can perform swapout 13% faster, which restores its original performance with rw_page. 200M swapout using MADV_PAGEOUT: Before: 4355ms After: 3786ms Signed-off-by: Minchan Kim --- drivers/block/zram/Kconfig | 1 + drivers/block/zram/zram_drv.c | 98 +++++++++++++++++++++++++++++++++++ drivers/block/zram/zram_drv.h | 1 + 3 files changed, 100 insertions(+) diff --git a/drivers/block/zram/Kconfig b/drivers/block/zram/Kconfig index 0386b7da02aa..a841d6d14c74 100644 --- a/drivers/block/zram/Kconfig +++ b/drivers/block/zram/Kconfig @@ -4,6 +4,7 @@ config ZRAM depends on BLOCK && SYSFS && MMU depends on CRYPTO_LZO || CRYPTO_ZSTD || CRYPTO_LZ4 || CRYPTO_LZ4HC || CRYPTO_842 select ZSMALLOC + select FRONTSWAP help Creates virtual block devices called /dev/zramX (X = 0, 1, ...). Pages written to these disks are compressed and stored in memory diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 5d258a28ec43..5e973c982235 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -33,6 +33,8 @@ #include #include #include +#include +#include #include "zram_drv.h" @@ -2170,6 +2172,90 @@ static struct attribute *zram_disk_attrs[] = { ATTRIBUTE_GROUPS(zram_disk); +static struct zram *zram_swaps[MAX_SWAPFILES]; +static LIST_HEAD(zram_list); +static DEFINE_SPINLOCK(zram_list_lock); + +static int zram_frontswap_store(unsigned int type, pgoff_t index, + struct page *page) +{ + int err; + struct zram *zram = zram_swaps[type]; + + err = zram_write_page(zram, page, index); + if (!err) { + zram_slot_lock(zram, index); + zram_accessed(zram, index); + zram_slot_unlock(zram, index); + } + + return err; +} + +static int zram_frontswap_load(unsigned int type, pgoff_t index, + struct page *page, bool *exclusive) +{ + int err; + struct zram *zram = zram_swaps[type]; + + zram_slot_lock(zram, index); + if (zram_test_flag(zram, index, ZRAM_WB)) { + zram_slot_lock(zram, index); + return -1; + } + + err = zram_read_from_zspool(zram, page, index); + if (!err) + zram_accessed(zram, index); + zram_slot_unlock(zram, index); + + return err; +} + +static void zram_frontswap_invalidate_area(unsigned int type) +{ + struct zram *zram = zram_swaps[type]; + + if (!zram) + return; +} + +static void zram_frontswap_init(unsigned int type, struct block_device *bdev) +{ + struct zram *zram; + + spin_lock(&zram_list_lock); + list_for_each_entry(zram, &zram_list, list) { + if (&zram_devops == bdev->bd_disk->fops) { + zram_swaps[type] = zram; + break; + } + } + spin_unlock(&zram_list_lock); +} + +static void zram_frontswap_invalidate_page(unsigned int type, pgoff_t offset) +{ + struct zram *zram = zram_swaps[type]; + + if (!zram_slot_trylock(zram, offset)) { + atomic64_inc(&zram->stats.miss_free); + return; + } + + zram_free_page(zram, offset); + zram_slot_unlock(zram, offset); +} + +static const struct frontswap_ops zram_frontswap_ops = { + .store = zram_frontswap_store, + .load = zram_frontswap_load, + .init = zram_frontswap_init, + .invalidate_area = zram_frontswap_invalidate_area, + .invalidate_page = zram_frontswap_invalidate_page, + .init = zram_frontswap_init +}; + /* * Allocate and initialize new zram device. the function returns * '>= 0' device_id upon success, and negative value otherwise. @@ -2246,6 +2332,10 @@ static int zram_add(void) comp_algorithm_set(zram, ZRAM_PRIMARY_COMP, default_compressor); + spin_lock(&zram_list_lock); + list_add(&zram->list, &zram_list); + spin_unlock(&zram_list_lock); + zram_debugfs_register(zram); pr_info("Added device: %s\n", zram->disk->disk_name); return device_id; @@ -2303,6 +2393,11 @@ static int zram_remove(struct zram *zram) zram_reset_device(zram); put_disk(zram->disk); + + spin_lock(&zram_list_lock); + list_del(&zram->list); + spin_unlock(&zram_list_lock); + kfree(zram); return 0; } @@ -2428,6 +2523,9 @@ static int __init zram_init(void) num_devices--; } + if (frontswap_register_ops(&zram_frontswap_ops)) + pr_info("Frontswap is not used, which is suboptimal for zram swap.\n"); + return 0; out_error: diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h index ca7a15bd4845..0f52d2da8512 100644 --- a/drivers/block/zram/zram_drv.h +++ b/drivers/block/zram/zram_drv.h @@ -139,5 +139,6 @@ struct zram { #ifdef CONFIG_ZRAM_MEMORY_TRACKING struct dentry *debugfs_dir; #endif + struct list_head list; }; #endif From patchwork Mon Jul 10 22:16:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minchan Kim X-Patchwork-Id: 13307697 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 7A150EB64D9 for ; Mon, 10 Jul 2023 22:17:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5AD688D0006; Mon, 10 Jul 2023 18:17:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 499BC8D0001; Mon, 10 Jul 2023 18:17:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3146A8D0006; Mon, 10 Jul 2023 18:17:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 1DFAA8D0001 for ; Mon, 10 Jul 2023 18:17:12 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id E532BA02A3 for ; Mon, 10 Jul 2023 22:17:11 +0000 (UTC) X-FDA: 80997113862.19.09BACBB Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by imf22.hostedemail.com (Postfix) with ESMTP id 5C110C0012 for ; Mon, 10 Jul 2023 22:17:09 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=KEiY6CnY; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=pass (imf22.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=minchan.kim@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689027430; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=8+4p6uJlpyQVP23aPliMbwA52rUCZU8lTEH3UMTHTIA=; b=ULyX4u1UtFsE8r6XVHIGAqsoz7qTbxLtPURpMwhhBXEOHH3N4CTU8+yDRgqaGIslF6n4tp Jt3Pp5I7YzfzF+pa+1HXe1Bmf1KnQqhj76Lo2ZfHguBQxFV70xKJy1ByR6tgIvMe6agUEF IhR7eE9zKkJny+Z35LazjF9S6VTZlyg= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=KEiY6CnY; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=pass (imf22.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=minchan.kim@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689027430; a=rsa-sha256; cv=none; b=ZdNVPE9nmxdLBrwrgCNMOQOIb8os9moU+PVc+p9O3CfAv82zljDXZjOb/1kaFMKUxNEcih 3VpQ6OCsgbVIhXztDiWo4kjX9icS42FHvJIk/Pb6V++PXMr0qkJKb2CWoCCpbgPImmOGJs 8XiVE21l8OE6E2YjUuCqw1m4VVAZia0= Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1b89600a37fso24710535ad.2 for ; Mon, 10 Jul 2023 15:17:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689027429; x=1691619429; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=8+4p6uJlpyQVP23aPliMbwA52rUCZU8lTEH3UMTHTIA=; b=KEiY6CnYA2FM2ZF0AeGtDSI1v8tvb59dgjzLZqEEVsZf24nOq8HP73kaYvzScDIx6O R5LumBWRpj4uGUtPS5YPmJja/WIAMG6LEJw/sUbr52WreSfGiNDv6SwL97Inlj3eHlJW DhFH3S4lkpIJv2ZvIYnk/amxtjEONbEnX8WAUpafl/6z3e+t4cQBGEUOEz1RLHEwGE6s mC5LmaPuLpHp/ujfudlW2xVDyU70I7o1PZum3lQ0JrPj0KrOzD0DR2/qRDRitOn3Ge6u WE4UVzLaOZXv95h6MyqEMpk2Hilv3/GFlBs8CDZqDrAiL4txAiy2pSk7iO9Y4NJg5F3A A3AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689027429; x=1691619429; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=8+4p6uJlpyQVP23aPliMbwA52rUCZU8lTEH3UMTHTIA=; b=T/MMHlhX9Z+IvGCBuAZBpYLp/T3aYlBW4rS4LLoe5kcEuX/BW3JCRV6l18lqG1tDh3 ENLDZOKCVIYXsLRWa7OCLyTIFeiuOa7mNtP6n0LpnClUcPAMS4GOSigqeIUf0+BPf3Xa 0YnZcbQaIGAgU9mFXvvhhg9iLizeflDn6OztZsfrlFbmVc+00/arbX8sI/XzHvRTV6ae st0oCkI25tziNHWG3c8GK8HGXGwfMkzJPbLSWxK8z67dpiovEX94pWIopPgYHt8I81XT C/OUZ36Pn4nAW9jBjCQoRnrv8XDPwjng8IRWNbYn79QLsXwSEHbAnY3SWpC5UyNyOVTd Bpgw== X-Gm-Message-State: ABy/qLYm7ISBP57vwXu973lHZSzSqrurhxAhYV1Q8U8vEKq2gSFVRfq6 jGxzKv+/bgnLtnMltieDf50= X-Google-Smtp-Source: APBJJlEfElRuE97E6JXfLC11FE5Gna/5aPWo7jqhQen+kgiFBTjYQJBAjEBWEhFJOV2KuUa/x+zo+A== X-Received: by 2002:a17:902:f546:b0:1b8:af5e:853f with SMTP id h6-20020a170902f54600b001b8af5e853fmr14188065plf.24.1689027428874; Mon, 10 Jul 2023 15:17:08 -0700 (PDT) Received: from bbox-1.mtv.corp.google.com ([2620:15c:211:201:1922:28f0:ba3b:368e]) by smtp.gmail.com with ESMTPSA id c23-20020a170902cb1700b001b9bebbc621sm376425ply.136.2023.07.10.15.17.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 15:17:08 -0700 (PDT) From: Minchan Kim To: Andrew Morton Cc: linux-mm , Jens Axboe , Konrad Rzeszutek Wilk , Seth Jennings , Sergey Senozhatsky , Minchan Kim Subject: [PATCH 3/3] zram: remove swap_slot_free_notify Date: Mon, 10 Jul 2023 15:16:59 -0700 Message-ID: <20230710221659.2473460-4-minchan@kernel.org> X-Mailer: git-send-email 2.41.0.255.g8b1d071c50-goog In-Reply-To: <20230710221659.2473460-1-minchan@kernel.org> References: <20230710221659.2473460-1-minchan@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: hsgcdtunnfo8w8yri6d5fgfr1oppaone X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 5C110C0012 X-HE-Tag: 1689027429-322013 X-HE-Meta: U2FsdGVkX19VscT6YbE3nbk24QtB08k2Hnvkpa/Vz+8ncbgCL3TWNpkImehm8lHU8otmK0ppD6tmSyq/ex1VrGZV6C8soek4MkVCcrk0BsqjChf53cb1Yh9tJWnuiP5NLgf0cxMr2ABTMahB6rUK0fMhCH88CIDiP9069d6Rn176+fU7mL+7CJ6WDrW7rrBpOd04v9bkF/Vz5SmP5mathiRUPxLYpPe/Q8uHX0DXRuaLrUGgspRfuQluj1TUD8WOeiqZgnPh5zp0+4XZNVvUv4IQRBkny1DsRLL4moT/ZTarLdJUP0pw30/XWVnNp/YBAqVHBYl3NRp7L1j+TUszVi+FZTVspoltS2eVKN5u5siFWcen/O/aOfm+LT4YGGQazRLO+y78Pzjy2PJrys7+sbJmp6iJ2gxRvc+ciJmgx7dh9MyrMzzvfGhFfJjNIPbtfwVLkAq3cmXnS+f3qCm519VxULyioyaCa9fhsW7wWq3OQZqqMpAU1UCES9oGmy0p+JsA9sJnxlimZreAy1ZOPOyK5M8Qyauugw88+/X2Fv2ufHCKSI/CMMKkVjVs/sWEx9IzarTZ71FwW+TMNo4oMs5jZIQHyGUS3VMpQPDMQ5iKCm1AhjZK9UplJXXt17vQ4hlyGL/1j5KRf8PYXPzTLSoB+XX9KkL6BH3y8z6c7N/ox6fzjRtx6/ekIwXAMl/DqWdBgZNORuj3W+1tVV/SWlu9zAevG3pxI//WPAbU6HWPJW/Zx+marqUWyJNwl+9USYWq8cHb3JXD4HyaCrqSQ/sPD0Ey6WAhtsSxZULG1uvs1dfixUIlYJaaW1tlkQSngKhNAOUripBglX1Rac7oUsJuJ4e2zjxs1YbORADBVyLfkBu/155GPKbK39E8Lqk3nybRZy5p3WuLfgH5aEWIew0ccPP5AnJVnbZnh36Dmk6FncPllqL7sYD6ZqHBMHPZK0HFcdD/jXZE7VjBDcl 257h+83I tNZ4bTEPmHSz96fOl4Jmu2Ixxu0ogt1gtT5cq0botjQOzHPKa/G/j2fo4Q79tmqsc77nlHae7PLEK96kx8KnLzQzuITj3bVcyTcKxodV2SwKCuJ0vbXHA9eM4vpJGMA54xFin0rngLNQ69/zSSAIJ39ZNZu/qvZ5sq3Ai9ebZt82OL7BloWUeLkY67w64zWFCzXgM95mWt59tOnge1LJNDl8qAvqXGdck9314aSNsEsmZpX/ZTn69WvALc2PJqS//aq5KChnXvnXhfGCDcQpXHkilnF9lIM6YFTsxxU9VAAnRuXPi7G/jBoSPd8fYrS3jTJz//kpKIxSpt9uyXRximw0S3UN0aHTCXGy3X/P9CHFj0aXvEBIq/NGRh118lD/Jbgq6vb191vpTbaDIl9MUCQu51mPaCJeGbfegGy293sfunWrexZUCyxd4vyfCvVZC+a7WzxXBFjAkEPbrn4v8ld1g53ubGBUE5gmf9MQgJa8TEqoGKOaDgVDhAt0bJYzDEbwoN1n8RnRyoImbE7gy2BfV0j3S5hzGW0EBVfUjQyanFMM0a1GznbiZltQMTgYn1ziQMBM6SRVc/bTaK6G14nCdvr6b2H/eI3MrgsiGL1eNXeZS38dr9xn+tEqoVvhYeYKF2h8KkasQsIDied6Vu8ZW+82WBWVSvBJj2T5hpuFDmqH8CKZ1s+60HVu7PGZX7+vl 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: Frontswap replaces the need for swap_slot_free_notify in block_device. Therefore, we can remove it. Signed-off-by: Minchan Kim --- Documentation/filesystems/locking.rst | 5 ----- drivers/block/zram/zram_drv.c | 20 +------------------- include/linux/blkdev.h | 2 -- mm/swapfile.c | 8 -------- 4 files changed, 1 insertion(+), 34 deletions(-) diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst index aa1a233b0fa8..c94ef7d9fc6e 100644 --- a/Documentation/filesystems/locking.rst +++ b/Documentation/filesystems/locking.rst @@ -477,7 +477,6 @@ block_device_operations unsigned long *); void (*unlock_native_capacity) (struct gendisk *); int (*getgeo)(struct block_device *, struct hd_geometry *); - void (*swap_slot_free_notify) (struct block_device *, unsigned long); locking rules: @@ -491,12 +490,8 @@ compat_ioctl: no direct_access: no unlock_native_capacity: no getgeo: no -swap_slot_free_notify: no (see below) ======================= =================== -swap_slot_free_notify is called with swap_lock and sometimes the page lock -held. - file_operations =============== diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 5e973c982235..ec040ab3ab91 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -1947,23 +1947,6 @@ static void zram_submit_bio(struct bio *bio) } } -static void zram_slot_free_notify(struct block_device *bdev, - unsigned long index) -{ - struct zram *zram; - - zram = bdev->bd_disk->private_data; - - atomic64_inc(&zram->stats.notify_free); - if (!zram_slot_trylock(zram, index)) { - atomic64_inc(&zram->stats.miss_free); - return; - } - - zram_free_page(zram, index); - zram_slot_unlock(zram, index); -} - static void zram_destroy_comps(struct zram *zram) { u32 prio; @@ -2117,7 +2100,6 @@ static int zram_open(struct block_device *bdev, fmode_t mode) static const struct block_device_operations zram_devops = { .open = zram_open, .submit_bio = zram_submit_bio, - .swap_slot_free_notify = zram_slot_free_notify, .owner = THIS_MODULE }; @@ -2206,7 +2188,7 @@ static int zram_frontswap_load(unsigned int type, pgoff_t index, err = zram_read_from_zspool(zram, page, index); if (!err) - zram_accessed(zram, index); + zram_free_page(zram, index); zram_slot_unlock(zram, index); return err; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index c0ffe203a602..49e1843e44ea 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1390,8 +1390,6 @@ struct block_device_operations { int (*getgeo)(struct block_device *, struct hd_geometry *); int (*set_read_only)(struct block_device *bdev, bool ro); void (*free_disk)(struct gendisk *disk); - /* this callback is with swap_lock and sometimes page table lock held */ - void (*swap_slot_free_notify) (struct block_device *, unsigned long); int (*report_zones)(struct gendisk *, sector_t sector, unsigned int nr_zones, report_zones_cb cb, void *data); char *(*devnode)(struct gendisk *disk, umode_t *mode); diff --git a/mm/swapfile.c b/mm/swapfile.c index a9424fd226bc..adc16d8883c8 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -726,7 +726,6 @@ static void swap_range_free(struct swap_info_struct *si, unsigned long offset, { unsigned long begin = offset; unsigned long end = offset + nr_entries - 1; - void (*swap_slot_free_notify)(struct block_device *, unsigned long); if (offset < si->lowest_bit) si->lowest_bit = offset; @@ -739,16 +738,9 @@ static void swap_range_free(struct swap_info_struct *si, unsigned long offset, } atomic_long_add(nr_entries, &nr_swap_pages); WRITE_ONCE(si->inuse_pages, si->inuse_pages - nr_entries); - if (si->flags & SWP_BLKDEV) - swap_slot_free_notify = - si->bdev->bd_disk->fops->swap_slot_free_notify; - else - swap_slot_free_notify = NULL; while (offset <= end) { arch_swap_invalidate_page(si->type, offset); frontswap_invalidate_page(si->type, offset); - if (swap_slot_free_notify) - swap_slot_free_notify(si->bdev, offset); offset++; } clear_shadow_from_swap_cache(si->type, begin, end);