From patchwork Mon Dec 16 15:04:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hyeonggon Yoo <42.hyeyoo@gmail.com> X-Patchwork-Id: 13909895 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 70F1CE7717F for ; Mon, 16 Dec 2024 15:06:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B48A46B00AC; Mon, 16 Dec 2024 10:06:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ACFF86B00AD; Mon, 16 Dec 2024 10:06:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 922366B00AE; Mon, 16 Dec 2024 10:06:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 33F606B00AC for ; Mon, 16 Dec 2024 10:06:05 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 75AB2C1112 for ; Mon, 16 Dec 2024 15:06:04 +0000 (UTC) X-FDA: 82901146902.04.40779AE Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by imf24.hostedemail.com (Postfix) with ESMTP id 63DEB180025 for ; Mon, 16 Dec 2024 15:05:58 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="FOrBjm/R"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.172 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734361534; a=rsa-sha256; cv=none; b=USKE1gg+lVqH2AgoWfIJQHRdOjRXPlclYXVNGOIUt78kruVrH6oLk626oeXgdeBT4PrJcW sk814rnTvCceZTw3c7ZYGU0474sBHujer0uyzN3n+osxG2/jAC2lLWM79JgXw45Q97yna9 cB4cEYvvEGDeuVh05aHPlX2qg6ExI3k= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="FOrBjm/R"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.172 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734361534; 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=WCbi/wYFFDEPej3gFSRK5hQu4Ni2dUdadNrYg20RN10=; b=60oRLdm/fdfEfSSW4OVaXj2omM3xMFShNGjm/9EHtv1XYtsvU17rSlCb4K4gZCtWv8N+HU mROxEYXwtkqn7yieCdoOOSseyiR0XKF/NwgAEFNVlu7ZCVDFM6HC0B1xDy9STXamyi460T 8N5G+F5OpULj88Y0iULPvFyIedxILPo= Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-72909c459c4so2619011b3a.1 for ; Mon, 16 Dec 2024 07:06:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734361561; x=1734966361; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WCbi/wYFFDEPej3gFSRK5hQu4Ni2dUdadNrYg20RN10=; b=FOrBjm/R6F1CpFqcjGYf7GrUQMXgBbVp0j4xxpafcpeRVLZCyo9lwuMOMyfn/X4zWN vPHG9P3hgkcZI7GbgtmrWV8mz7LSvHeKVeEaCU0xcY7gQv/HuHNHJw92a31CnITmgvMZ BCyBZ5yj18t7qz3G6z016L/Er3nAf3ymDbZvtvOEK+Wp8AeLXupakeH1yNztIO5eOG68 HToI6eR8729/6LeLJjRYyODG8Ubqwm0W0ZsZpQ57MVdUJQhkfgfXLNjikjRXOlRRR95U W+DK6lPoxCc6v7dOt2DU4ZKKkm9oMwrMyvEJ9sPJ4nes+53d8MP1D1yFUiyTsR5xfONH Lglw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734361561; x=1734966361; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WCbi/wYFFDEPej3gFSRK5hQu4Ni2dUdadNrYg20RN10=; b=h7IJyMJK/SQuEdFU39EfuDXf/qv8I7XT6zgv5dujx2ZNVuzXMZTjARqoM7oKLhBZ05 8OKX+EdX/LESER5npu+4R9PLL5mfnIH+mS0VOKJxSb8EU0QBh+y6h9GApbmRJYZ/7NS5 gFGghET0z5LW46BC/zSErxBFGEESQfpG98jIlWopATNMVutNW/6lSsq8o9Gd8iMwQwPh WwgBEntXwLyVknh0T1q/bxuaMftHLtdApihcmcUwY97ozDK5lMrqCOJR+99Ed60v+NV9 4DGYuPQ9xxnxiT/AVleXw2S07e9vpiJAR7Awoj8nYE2d+e0GG7gK9crWBOJKP8zh5Oiu SJzQ== X-Forwarded-Encrypted: i=1; AJvYcCWJIP0fdYpuTJmxMwFMFM2XJO+V4wmFNXMVORAI0SVcAByGm80a2j0HtJSdBSwX12rys9de5kOgGQ==@kvack.org X-Gm-Message-State: AOJu0YyioqNZMFI2kKru3CtMM/ztc4iQhqrK67rMucs0afF3sS8xBETn sO/vcPgjei2sDpz00vv+nnQGdD+n9l/Zadxs2WH5FDtzzMgFOUjS X-Gm-Gg: ASbGnctBQakabPSQ6sviPuYNtoVHZBCpyeqt78FKW8/qL7xJrKOc81MouyQcDm3qYkA Y43yeo56RH0xWyPvIURj8qEl3fYalgZ9Pg3r7nPzG/u0hsLYhzs/X75GPZt70f+l2AcK0qRT3yn yohVcyHEWMBlZcb6vGm1bvlaTqcCtLKpPvKwEt5hyn4vHoPQJ9t5kQrGExexh09FICqWl/DZm22 HUoxwTHIVEbXC+P/Iu1HusiweXC+7QxITtUCLQGW7qI5dvnBBYt4lsBbqYuffcWqsY= X-Google-Smtp-Source: AGHT+IH/s+RFXtaht2G5asEek3t03T8vImc3qM4E+LL2aV0R9WqYL6WbCP8vNnNKFmkQJ8P11BD0dA== X-Received: by 2002:a05:6a20:734b:b0:1e1:aab8:3887 with SMTP id adf61e73a8af0-1e1dfe3f1f4mr21870385637.39.1734361560739; Mon, 16 Dec 2024 07:06:00 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ad5ccdsm4845518b3a.74.2024.12.16.07.05.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2024 07:06:00 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Andrew Morton , linux-mm@kvack.org, Matthew Wilcox , Vishal Moola , Alex Shi , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Alex Shi Subject: [PATCH v9 mm-unstable 17/18] mm/zsmalloc: convert get/set_first_obj_offset() to take zpdesc Date: Tue, 17 Dec 2024 00:04:48 +0900 Message-ID: <20241216150450.1228021-18-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241216150450.1228021-1-42.hyeyoo@gmail.com> References: <20241216150450.1228021-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 63DEB180025 X-Stat-Signature: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FZYU0gD5luaN4wgLn+Y3p2Q5xQvnH7HfSP/6PatrgNCTphGXJ+pAtQFaFovChLc5DP43/l2zhIAuHhCgosEgWtcilTvBcfPYYCoxTO8IzpUZp7wXUbxC+7frXjr80iO1+zE51IEJTfnSVOs4R9gJN6weimBeiNOa5af4RXvtyUDolc71nmDovkpl3ziYNtGh0M9tzlwBEl77FKTE6S8K7aTXAL1Wf9QVkBQicv5fZUmyO3BKw0E1rLRft2wAgcfDqKD+zplRRfGN+yPLYh0w1wl/zET2l2/3Q+dV+IywJnazNj5S8rHY1XIpSALc/Xa90LpnMqyaurYvhdyRdqjYJAi30wYLd1pY3OIv+zstA0z4iXjFvCBk5g8TjLoF3U2DENOLRct/K7u9RyTsfve5UNXy8kbNgRdFVcX9j/D3SfeGTm4M07F9Y6cfErwa58JcaMfMB2W30SvX9YEgcvJFb9iIZK0ifLuIetXNX51WZhgeCUd48ZkQ0dDCqSAPs23NC1NWTftqhROPRAIBZmle+g= X-Bogosity: Ham, tests=bogofilter, spamicity=0.163894, 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: Alex Shi Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 1801dce2f7ca..3a841e16746e 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -478,20 +478,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)); + 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) @@ -911,7 +911,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); @@ -1555,7 +1555,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) { @@ -1750,8 +1750,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); @@ -1806,7 +1806,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); /*