From patchwork Thu Dec 5 17:49:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13895930 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 50D70E7716E for ; Thu, 5 Dec 2024 18:09:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7D05B6B013A; Thu, 5 Dec 2024 13:09:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 780386B014A; Thu, 5 Dec 2024 13:09:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 647D86B014B; Thu, 5 Dec 2024 13:09:13 -0500 (EST) 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 43B006B013A for ; Thu, 5 Dec 2024 13:09:13 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D99C61416D2 for ; Thu, 5 Dec 2024 18:09:12 +0000 (UTC) X-FDA: 82861691640.30.A355041 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf18.hostedemail.com (Postfix) with ESMTP id C68791C0007 for ; Thu, 5 Dec 2024 18:09:03 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=iXP5YhWZ; spf=none (imf18.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733422136; a=rsa-sha256; cv=none; b=ZJkg0GICOTAyM99q8MGpuhvcGrkHDPrPecDa2nD7kOcZv8jAxb4tHXJo59vTyAcjWhE6o3 STLygAq8qutqBFplKVKKVp0i1OzNhHso+zA7ie8P+BLIfTKqtR0ilAYNq085J4sUuq3Dkx nMk995wFG7UPkugv6jAB+/v/GiYclHo= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=iXP5YhWZ; spf=none (imf18.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733422136; 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=7a3VGducrMVXQ9/iNeGwmenmfpj1ag31Du6oIOBWz8g=; b=eJEx2m1ndDeqhIFxx7Pg0vikqG2i6QxWyu3Sip2qxQwsRNVCorG0wVQvMIJJEXuNxNpYsl diXKEh5G9UnuQLZxfkWNDa7acy7F/ghl9pzyxDc7oZFd55bHOrexjsCDbBhBDlKLrgdOo7 m2aWA3JyraP/mpKXIk2G5yE0R//a8WU= 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=7a3VGducrMVXQ9/iNeGwmenmfpj1ag31Du6oIOBWz8g=; b=iXP5YhWZzbxSYWZ7PtRqxOtzVl oT86dz9cIxtF9tjbyO0EDZxeGZXqZ8Drjj9Ws3bDD4ylhQJ6cEc3fpqK2cZXi3hMUfqIod0vOiVq0 5VTVxRn3Aq84wonM2UuA068DW5B6kjUn/211I2SdU/dzED4EeU89PE3BautwLLMrfYz5hQfaBGhBa 1o+5L9d+OhMfqtQlPNszdB7vMP5LEKfHyziWmk7ft5MTO7Mqx28LjArPN19bJIYg7pZvu8uWW+Tgr R4UV1UVtST7SPdUwEFXqNsSPovN7cjS3kK0qSRyZPQJtz9kyyeSGiEhrIav3JXLc7u1NsVg5sI02r Pae9TZaw==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJFzI-0000000DN95-147l; Thu, 05 Dec 2024 17:50:04 +0000 From: "Matthew Wilcox (Oracle)" To: Minchan Kim , Sergey Senozhatsky Cc: Alex Shi , linux-mm@kvack.org, Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [PATCH v8 17/21] mm/zsmalloc: convert get/set_first_obj_offset() to take zpdesc Date: Thu, 5 Dec 2024 17:49:54 +0000 Message-ID: <20241205175000.3187069-18-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205175000.3187069-1-willy@infradead.org> References: <20241205175000.3187069-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: C68791C0007 X-Stat-Signature: 88jskarg3xqscmdk8qmkum9ra1iaci33 X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1733422143-779078 X-HE-Meta: U2FsdGVkX19/yogg30lzyYJLWLpBGR4RWIaGArNMbGTmIJpNq99n2S80OV0wIUPCaq1ONt0y9W6oSefCZodIJGy9f7fH50HNzFx4//0AsuFfUoxWGeBEs6cq1sgIaNjpJmD/hLRe7KRRcsJ5cjytzGW5VTh8yNIVRa57PBwNSDvq85qw8/Ov31UwCmY9z2YAPJTMXFYXxXLM9nsl3qCakGaEy1cpX7e7vJBexDMhaHVIYmXdBkRihT/o2/B0QkJ72CwWBngEjix6bLmflZc2jJ7PjTXckzN6ajOagMir18Gq3pFRp78CKfwFTcU8bJ2z0q+syPvMjhegHpFih2TSrky5LxlofOaqrngF3CBd+bcefswCAZTLRpXyDYtMuBxkRd3VesQYJXFkWel23LQv62a7HmR9p0yIC9Ix9JxtVR6kqDwq1hXOJMM5TkawkbPffK0sIlPxkayCPKJIBBbWpNJxN0knHM/lCzkyP2QxBglcvo+/9ekQq302of4BrExHlyh4jlgIWHzVOFURhInGgEzBjvVoDTtMUsF5epx2QcJCJkyE9oBEpL2p1hkEtouzvetGQIvZgBzNz2rMGF0g70Ez4mRiNDB1TepYqYBuGiqHVlNY+uPb0sNNh7Ln9aUrxZZbmKGWR4ZlRWRAAqMYzCwhu/9p+LnhDeCpildfZX5n9Wkcyav8RCg2cTGMde8FzN/wR8N5ilvIeR0RTxfEuXO+ImKlD02DxlOznH7wuDzHUc5WTueV0PGW2ovpTDDsczY5Wrh3TpMiv6LdBztmSDHV1IlifP4+ksQw31qkaH/9wWB7BOENGARd3mllTziTV6kp0MBm21HQ8/6FBASK4xlb9tC+EDWyRYI6I7bivOio6713eTUQNeJfsgmrGIEVTIknNAHuRpXVQh6pyaub/+jEuZnpRuYh3BceAwUC+iZvGqna3ZK16BU2qD/u+AXU7DVpd5gg12QvxeYkMH6 GT3ZmhLv +IN+ymxZSXfq23xFpF2anYpBGSD3oQWEboOkmD93hWF/7xvanoC/jdNL6PstlpEy4YAs2k1Fo1Mfe1Z9h6FZeNPB6u6sbB9a1qfXdVaaRoTSKoFrLUuFA/2H2Kk38+TvD1udwcZFq3aSFq1uXMApVjlOHVsjB1ot62o53hpWleku8NyVTE6TqH7dW1JXUWQXlHdaL47X/jDpPtiUIsOY2lYpapMiL8H8fJWhwYZbtKglFjg1Ia6FYd4/0mC1+s49F9WW9HWBLOlLsYxh2/eO7mBwQLb0i6dbbuKc67DyDDOSY+WttGvziU29Ny02YguTVE8L3HBH0zZC4hcd8A+UEm3DOWQ== 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: From: Alex Shi Now that all users of get/set_first_obj_offset() are converted to use zpdesc, convert them to take zpdesc. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zsmalloc.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 16e3d6705563..a15bdcc25bb3 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -496,20 +496,20 @@ static struct zpdesc *get_first_zpdesc(struct zspage *zspage) #define FIRST_OBJ_PAGE_TYPE_MASK 0xffffff -static inline unsigned int get_first_obj_offset(struct page *page) +static inline unsigned int get_first_obj_offset(struct zpdesc *zpdesc) { - VM_WARN_ON_ONCE(!PageZsmalloc(page)); - return page->page_type & FIRST_OBJ_PAGE_TYPE_MASK; + VM_WARN_ON_ONCE(!PageZsmalloc(zpdesc_page(zpdesc))); + return zpdesc->first_obj_offset & FIRST_OBJ_PAGE_TYPE_MASK; } -static inline void set_first_obj_offset(struct page *page, unsigned int offset) +static inline void set_first_obj_offset(struct zpdesc *zpdesc, unsigned int offset) { - /* 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)); + /* With 16 bit available, we can support offsets into 64 KiB pages. */ + BUILD_BUG_ON(PAGE_SIZE > SZ_64K); + VM_WARN_ON_ONCE(!PageZsmalloc(zpdesc_page(zpdesc))); VM_WARN_ON_ONCE(offset & ~FIRST_OBJ_PAGE_TYPE_MASK); - page->page_type &= ~FIRST_OBJ_PAGE_TYPE_MASK; - page->page_type |= offset & FIRST_OBJ_PAGE_TYPE_MASK; + zpdesc->first_obj_offset &= ~FIRST_OBJ_PAGE_TYPE_MASK; + zpdesc->first_obj_offset |= offset & FIRST_OBJ_PAGE_TYPE_MASK; } static inline unsigned int get_freeobj(struct zspage *zspage) @@ -929,7 +929,7 @@ static void init_zspage(struct size_class *class, struct zspage *zspage) struct link_free *link; void *vaddr; - set_first_obj_offset(zpdesc_page(zpdesc), off); + set_first_obj_offset(zpdesc, off); vaddr = kmap_local_zpdesc(zpdesc); link = (struct link_free *)vaddr + off / sizeof(*link); @@ -1574,7 +1574,7 @@ static unsigned long find_alloced_obj(struct size_class *class, unsigned long handle = 0; void *addr = kmap_local_zpdesc(zpdesc); - offset = get_first_obj_offset(zpdesc_page(zpdesc)); + offset = get_first_obj_offset(zpdesc); offset += class->size * index; while (offset < PAGE_SIZE) { @@ -1769,8 +1769,8 @@ static void replace_sub_page(struct size_class *class, struct zspage *zspage, } while ((zpdesc = get_next_zpdesc(zpdesc)) != NULL); create_page_chain(class, zspage, zpdescs); - first_obj_offset = get_first_obj_offset(zpdesc_page(oldzpdesc)); - set_first_obj_offset(zpdesc_page(newzpdesc), first_obj_offset); + first_obj_offset = get_first_obj_offset(oldzpdesc); + set_first_obj_offset(newzpdesc, first_obj_offset); if (unlikely(ZsHugePage(zspage))) newzpdesc->handle = oldzpdesc->handle; __zpdesc_set_movable(newzpdesc, &zsmalloc_mops); @@ -1825,7 +1825,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, /* the migrate_write_lock protects zpage access via zs_map_object */ migrate_write_lock(zspage); - offset = get_first_obj_offset(zpdesc_page(zpdesc)); + offset = get_first_obj_offset(zpdesc); s_addr = kmap_local_zpdesc(zpdesc); /*