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/5pk8lkCBmapyWIqPVK0dhsEuxrQgSd0kjQcajPIwHENmRCRdS3ymTENUvVC95LYXSPxkk0GwdMqag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KWNd4FdpyYOOMvnAkdzPcE9wtZqHrF8aA3bk7Ga4Jw22IfvVlPrvtsxoIaeqbgpfiovUjujBASObWpRw8y88HZRaeSCcnqKX3TR/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;