From patchwork Wed Aug 21 17:39:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13771931 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 B4FB5C52D7C for ; Wed, 21 Aug 2024 17:39:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 46FED6B00AE; Wed, 21 Aug 2024 13:39:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 41DED6B00E7; Wed, 21 Aug 2024 13:39:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E6086B00DE; Wed, 21 Aug 2024 13:39:22 -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 11DFC6B0163 for ; Wed, 21 Aug 2024 13:39:22 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C17C91A1009 for ; Wed, 21 Aug 2024 17:39:21 +0000 (UTC) X-FDA: 82476964122.21.AEF2C6C Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf29.hostedemail.com (Postfix) with ESMTP id 9393B120009 for ; Wed, 21 Aug 2024 17:39:19 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=tOoYZbVB; dmarc=none; spf=none (imf29.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724261901; a=rsa-sha256; cv=none; b=kM8Ircl/HCO+gBQpUfCb+saDzDvxzno4SPaoPhAb4yt27ckMBQtuVxfmzTOxfhY+g2VPqd sGo/D4YGtN4rZkvxTWyIkXt9CDTD2IDR50jL1ALniTuwmXjIgAemn1v8H79EjbesqTNI0Q R23hL2FIk4cevcnXe8zhTuhSiAwo3zA= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=tOoYZbVB; dmarc=none; spf=none (imf29.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724261901; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=5DI5wKlXZGZKzwJ/MCoQ3cQHrHQLIvS5UVq04Bxcppo=; b=dZhVMmxVkzcSSeUqcod0rdjHpg8UW9qESJ74ke55n0u16KysQoKquWRDAeB9X/OOwhfM6r OaNkIklHwB5pqY4rpV9q0VlPr+UbGOPeTOxNeqSAMHOnnU5aYwspDz80eN02xzc0UWnJve U4k6B6393O1irzwbYRFHBOOSlNFvkCs= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=5DI5wKlXZGZKzwJ/MCoQ3cQHrHQLIvS5UVq04Bxcppo=; b=tOoYZbVBS/v0VTE0UFNURp3T9F SCj1/GCKHGgukcmtJkttB3xsdRSmavRKbta+N6gxcp6BLXMv2FXcnB3r/HVB6H7wXK/k1uVCYEpt/ nsFJBf2VxqFx1meg3aGp6u7tT/+tmeCOKQAIslnZLluV3wqxba8WSVgUxKJ2+eUV2HSKVN/znOwd2 HVPsJGDe2cHUNkOtTsDn3o1RUW+DXojI+wqjd4BHMorMdFKUYniSH9XZNK9dDQuw3cJ4HBlyB80Bs tc70e9uX54wB1WNQOsJ+EqspUnTfpsRPXjFZ3D94+V+JmvW5oHqZ6NdmLS9H7rx6pSD3Baaxnwho0 MEVAvuQg==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgpIi-00000009WdV-247v; Wed, 21 Aug 2024 17:39:16 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , David Hildenbrand , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, Kent Overstreet Subject: [PATCH 4/4] zsmalloc: Use all available 24 bits of page_type Date: Wed, 21 Aug 2024 18:39:12 +0100 Message-ID: <20240821173914.2270383-5-willy@infradead.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240821173914.2270383-1-willy@infradead.org> References: <20240821173914.2270383-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 9393B120009 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: y1yso7am1qhx39mss7awbcuy3oq4u3t5 X-HE-Tag: 1724261959-752623 X-HE-Meta: U2FsdGVkX1+K/x+Vup2vtsGsHQ+FRwuEA5M6lZ8oieGNxUIEdUqqW9yLfaanXKKrWZnAz+jgQMhgltjX8LYXCCFDlY7APw3YwGq8PhV7moIEDDMO1oltPGXlCPisxlcgiK+DB+ys+ILGq5vEEXDzkhf8gOdE+QjBgDFbodEgZIN0OwCB4oC9dzFCna/ZlGqYyWaSQPFPQyyrMi0tEoZmBGmHEVfNotLiNBGmwXS8VzxSCW+gqPWTPxgMC4TSOUq2/8ijw1AWRB67lUcG37vDc0Gk87BZzVA6xIx41LYhBwcA4XJdxy5Xl/3wAhtiDpd0yKjJohCRrEX3W33dkCmZIxo2wCtb6kjEgf+T2o67XJjRxF1VojeoHRNob96gsA4p07+km9s0yFs8cEMlvC7pyRN01heaAfWK8L/UbpFdljQ6BkR0SXAcmjTurwPp6797zW44liKb/aK7t102wO3uaU479hFGPrT6Ic5/otZ6jYDa7K0Na+P4RZcZx4CgZ/kr6fSENexBFrY6tnymwOY0HtaIYwTkSsORfsvZLzUiOUGQGMUECz2K5RNeYqMJgSlnmswYbVr6wbSLc4sL49XLr2jxrzJWKOnPYoKKZthX+/4S5/ScK/j08cFkMB1EP37ZVERPKjdGIgLRO12wrNWrPL8c2ll9uwz+NM3lgBUrn8VuJb7Ic3j5ZI0mTEQ2RTyeL4/hzQe4+1Be65VMbv6q2PKY6ko+wleuipX98dxAtc5zaZihnm64BwHE/dGOqVhHIgjApi5kp6jZe5vrmtmLLHNs+iP3X/PaY4a2yhKZ8V1kFLLemtlQeSO+1I6hSo7+FK98hZYFeOiErm1bXyVULJ7CMIOnliZs3oJgGzJ3eK9ODtkVafx3/vPltprZr9ptlnKtwQi4G/d1bKRdOl7Zxg6Wr3MLOCnCUgaiZaU3B1dO3VWPNaruwV79jPYtew8hw7hhQ424eTi62oa2Rws exEpyKgM 9p2RK2Ru9qsOXijxLxD2oZek+X7BVUPyW0RfkNAQ/3/yiYET8xwVOMOid+nP2Go6YPIQ4UZofXKbY97c74XAHADoxShH+lUnH0a1NOFnCfApnzBp/WDwS2rtNR/A8MXEYorYwZVLZNpH8U2YmGfCUlEiCqqB9IZ3Sn8wfBOk62/TDCD04qtg9OKmbGLUr6H3QUp9K4smadF1rP0qn3wmFTX6SyP5vXB2Bbcld3CO6n56gKOiEn7tBC1V1RNpVWpxLHS5W2i6fJq8aakFbHbs2LdgJ1HAHzD59qgS4fcwppT8YDbwu2re1xKStKUoOK3pSj8H33C4BHjSlPVY= 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: Now that we have an extra 8 bits, we don't need to limit ourselves to supporting a 64KiB page size. I'm sure both Hexagon users are grateful, but it does reduce complexity a little. We can also remove reset_first_obj_offset() as calling __ClearPageZsmalloc() will now reset all 32 bits of page_type. Signed-off-by: Matthew Wilcox (Oracle) Acked-by: David Hildenbrand --- drivers/block/zram/Kconfig | 1 - mm/Kconfig | 10 ++-------- mm/zsmalloc.c | 15 ++++----------- 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/drivers/block/zram/Kconfig b/drivers/block/zram/Kconfig index 40e035468de2..6aea609b795c 100644 --- a/drivers/block/zram/Kconfig +++ b/drivers/block/zram/Kconfig @@ -2,7 +2,6 @@ config ZRAM tristate "Compressed RAM block device support" depends on BLOCK && SYSFS && MMU - depends on HAVE_ZSMALLOC select ZSMALLOC help Creates virtual block devices called /dev/zramX (X = 0, 1, ...). diff --git a/mm/Kconfig b/mm/Kconfig index 3936fe4d26d9..5946dcdcaeda 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -128,7 +128,7 @@ config ZSWAP_COMPRESSOR_DEFAULT choice prompt "Default allocator" depends on ZSWAP - default ZSWAP_ZPOOL_DEFAULT_ZSMALLOC if HAVE_ZSMALLOC + default ZSWAP_ZPOOL_DEFAULT_ZSMALLOC if MMU default ZSWAP_ZPOOL_DEFAULT_ZBUD help Selects the default allocator for the compressed cache for @@ -154,7 +154,6 @@ config ZSWAP_ZPOOL_DEFAULT_Z3FOLD config ZSWAP_ZPOOL_DEFAULT_ZSMALLOC bool "zsmalloc" - depends on HAVE_ZSMALLOC select ZSMALLOC help Use the zsmalloc allocator as the default allocator. @@ -187,15 +186,10 @@ config Z3FOLD page. It is a ZBUD derivative so the simplicity and determinism are still there. -config HAVE_ZSMALLOC - def_bool y - depends on MMU - depends on PAGE_SIZE_LESS_THAN_256KB # we want <= 64 KiB - config ZSMALLOC tristate prompt "N:1 compression allocator (zsmalloc)" if ZSWAP - depends on HAVE_ZSMALLOC + depends on MMU help zsmalloc is a slab-based memory allocator designed to store pages of various compression levels efficiently. It achieves diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 2d3163e4da96..73a3ec5b21ad 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -20,7 +20,7 @@ * page->index: links together all component pages of a zspage * For the huge page, this is always 0, so we use this field * to store handle. - * page->page_type: PG_zsmalloc, lower 16 bit locate the first object + * page->page_type: PGTY_zsmalloc, lower 24 bits locate the first object * offset in a subpage of a zspage * * Usage of struct page flags: @@ -452,13 +452,7 @@ static inline struct page *get_first_page(struct zspage *zspage) return first_page; } -#define FIRST_OBJ_PAGE_TYPE_MASK 0xffff - -static inline void reset_first_obj_offset(struct page *page) -{ - VM_WARN_ON_ONCE(!PageZsmalloc(page)); - page->page_type |= FIRST_OBJ_PAGE_TYPE_MASK; -} +#define FIRST_OBJ_PAGE_TYPE_MASK 0xffffff static inline unsigned int get_first_obj_offset(struct page *page) { @@ -468,8 +462,8 @@ static inline unsigned int get_first_obj_offset(struct page *page) static inline void set_first_obj_offset(struct page *page, unsigned int offset) { - /* With 16 bit available, we can support offsets into 64 KiB pages. */ - BUILD_BUG_ON(PAGE_SIZE > SZ_64K); + /* With 24 bits available, we can support offsets into 16 MiB pages. */ + BUILD_BUG_ON(PAGE_SIZE > SZ_16M); VM_WARN_ON_ONCE(!PageZsmalloc(page)); VM_WARN_ON_ONCE(offset & ~FIRST_OBJ_PAGE_TYPE_MASK); page->page_type &= ~FIRST_OBJ_PAGE_TYPE_MASK; @@ -808,7 +802,6 @@ static void reset_page(struct page *page) ClearPagePrivate(page); set_page_private(page, 0); page->index = 0; - reset_first_obj_offset(page); __ClearPageZsmalloc(page); }