From patchwork Mon Dec 16 15:04:47 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: 13909894 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 675C9E7717F for ; Mon, 16 Dec 2024 15:06:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5C9176B00AB; Mon, 16 Dec 2024 10:06:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 552A46B00AC; Mon, 16 Dec 2024 10:06:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E0856B00AD; Mon, 16 Dec 2024 10:06:02 -0500 (EST) 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 0C9A76B00AB for ; Mon, 16 Dec 2024 10:06:02 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7B50012102B for ; Mon, 16 Dec 2024 15:06:01 +0000 (UTC) X-FDA: 82901147070.29.2919A2B Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by imf29.hostedemail.com (Postfix) with ESMTP id D3D67120021 for ; Mon, 16 Dec 2024 15:05:17 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Lmev8qao; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf29.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.171 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=1734361545; 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=Giyc6imQIJdJczErUr69pIQpgrMAMbU/kKt2HxXelDw=; b=ayly1IK4iqJpR7VYewyVR5SCcuWd3iMiqdtanHqDYc4BTSLonlmK2o5tunAlDf3dzeW9ub wzLY45yDTd1CUDSj70J06an/MMmNw0cMazQbdKq/Tfr5IYkUkiKDvxqArQm8WMMFQoTd0L WZDzGlwqCQZjhQ9MwSbIEMA+V4ahHpE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734361545; a=rsa-sha256; cv=none; b=ycBCeCjieSLmPUTNuWkSSdrzcmONUdRkO6TY7jeuhzzrSYvLGeh+oZPIa4IRlhWKwkn8bq HsvkwZnOqmCtT8J0d0s7whcRkykaQ8sFq+YeXo4wT+/IOS9NG2W1eXh5U2JV6OpZpiJWZu L//fjrVCKE44kgEHQKPCdXLkBEVkom0= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Lmev8qao; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf29.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-72909c459c4so2618984b3a.1 for ; Mon, 16 Dec 2024 07:05:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734361558; x=1734966358; 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=Giyc6imQIJdJczErUr69pIQpgrMAMbU/kKt2HxXelDw=; b=Lmev8qaof5N8rXxH00WauvH6u1+VJH5ZJqVO1bPyiuetXr6kijT79zWS+W77iIy3Q1 tmqoGt6BQ7XEX9r0MFtPj0F7a4WKrZBy3z9iCHdh5SkfL6K6/BhC8LJmYal+tPwHEBUH yJ+970BVqXaKjW3NHuwRIjBTuS48pa4biNuHDwgFxwktlGN3e5p8TvNM+w/oM2ena6Zi lTz7tpfiZiPNzyI1mJwJ0BVzEIa36svDaOsSUFPjw9hWCkl2sVS3I4+gtPYn5WSFf1/d ygoRcB7SGA7JR3ft1FTKeY9/5rOfrzuE9oAENhhrxkBup+xfms+TGzPVwyBsJ2+TPUJZ 496A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734361558; x=1734966358; 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=Giyc6imQIJdJczErUr69pIQpgrMAMbU/kKt2HxXelDw=; b=t+3S7yaxIFX4Cx0Ljur5CpIKj7Q5cz74z8tkDxKgfI1Qeyd1dnlgrwd34VO3g4RVZI La1ZV7zHloBB24P52KbNg0QLUemZFJB/m2zJFwHnBwZVgetyP8AK9ugRKMwZFN72ijLv rNWs78icb+WXiy4F7l0njfPGFspPn4oKhPohkerfvbRp8bN6+uB9++NIiwvd3OZFKf+y IVawe7+FWH2aXWEJgdEX5+yCbXm5R940H4QihEpc6kwQd5JEGcVv2ciMqyioYb3rHcEn Czl0N+RgpAlrm+SI2KM04sf45fQLjjnRrN/L/GZDU+xsS57xIjZA67MvZUag3gvowGH7 LHWg== X-Forwarded-Encrypted: i=1; AJvYcCXLTMebJMoYmgw2SfqwZ0ENFcOa1/ATI42zyFBIWwwZ8k8tDi9l/m8WWe+erk58opGVcT7cHRaSYg==@kvack.org X-Gm-Message-State: AOJu0Yz9gum5A2LDVFoTg0HS6QZTzb33qa2WNHfm0ydOfa64lltERDkm dk9CiKEtq+qaGsb52qyOSNRe5u5opYQTWwgigp+DC2+puymIjEYJ X-Gm-Gg: ASbGncu8Ae/iLkdWh8GOtlOs9VuVbDQSy965zfyuqWl1om8l1oKq3TNm3tTMCHt++A6 VCfs3//qYWRzwJZ9HhNGLryJg2ezYrhV1ujZBu4DE+yfEIaGrePjDkpr72z2WUQd4Ahr3TxZlFg NfEcpNgKBtAF7jEkghgg6SqQX6b/Vh93yzOptlpi95Fex0ipV47ea8610z65jXz85w6MBw+Vfpq 0mHTgaOS/ZvFcnQnVXl8o2pI8FVXO/W/ffNB+/KvGk9HEyJL7gWblarA8QxfxufvLE= X-Google-Smtp-Source: AGHT+IGv6hjUbxOOmjqtrAkaNIt0VwqljePea/Z4ZmFIAwKho+N/vYjdU4QRl3qGQbfx/Ng2EAXkNg== X-Received: by 2002:a05:6a00:6c8c:b0:728:b601:86ee with SMTP id d2e1a72fcca58-7290c24330fmr17274605b3a.16.1734361557657; Mon, 16 Dec 2024 07:05:57 -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.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2024 07:05:57 -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 16/18] mm/zsmalloc: convert SetZsPageMovable and remove unused funcs Date: Tue, 17 Dec 2024 00:04:47 +0900 Message-ID: <20241216150450.1228021-17-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-Stat-Signature: supmmfcoic4dex6dkmysyroj4psxeofp X-Rspamd-Queue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RW6HJFsfQqkg8GVVVezFWEyhLIGfPp0JJp8f6m8jbY/zYmg7rQ+LLKI3Ag7OcL6QJrK4/g255GUHgSYjsHnoIN8vEajUM4h0kgHaI+3/PMgah5QGbNvTCGYpFfIoWekRyvbQUVFTAw/gd5YWPSvY8BKSXr3ChOLW76Ze2i+vRqRtC9eccN8rvDBuQETuBg9jIu+/6TOZlped+CqBVSjubxaHqDB3hWHE79As9mCa+rD6YoVtZZRY4bQ0y48baURfTKAG0uhoYkHnX/t6bOW6Ce7hxYoqyZ9YQeHkX9RAxi7cX82twIAcv6IsRfQXvfSUoMXb4KyLnpUgZU2/URc6HHGjer9IbFQT7F0gKRYeHkKIa9tUXLYR6jJr9B0as6LU1QRG/IyUs92AuNGLbiVd4BQOyvG3p8TC7OPiLjIvbmLZYX2b+mx3hBrK9fhKnfliOtyDHQ/wePBh0LTOaJchJbxKmvWCEQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.363543, 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 Convert SetZsPageMovable() to use zpdesc, and then remove unused funcs: get_next_page()/get_first_page()/is_first_page(). Originally-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index a1a620192596..1801dce2f7ca 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -452,11 +452,6 @@ static DEFINE_PER_CPU(struct mapping_area, zs_map_area) = { .lock = INIT_LOCAL_LOCK(lock), }; -static __maybe_unused int is_first_page(struct page *page) -{ - return PagePrivate(page); -} - static inline bool is_first_zpdesc(struct zpdesc *zpdesc) { return PagePrivate(zpdesc_page(zpdesc)); @@ -473,14 +468,6 @@ static inline void mod_zspage_inuse(struct zspage *zspage, int val) zspage->inuse += val; } -static inline struct page *get_first_page(struct zspage *zspage) -{ - struct page *first_page = zpdesc_page(zspage->first_zpdesc); - - VM_BUG_ON_PAGE(!is_first_page(first_page), first_page); - return first_page; -} - static struct zpdesc *get_first_zpdesc(struct zspage *zspage) { struct zpdesc *first_zpdesc = zspage->first_zpdesc; @@ -765,16 +752,6 @@ static struct zspage *get_zspage(struct zpdesc *zpdesc) return zspage; } -static struct page *get_next_page(struct page *page) -{ - struct zspage *zspage = get_zspage(page_zpdesc(page)); - - if (unlikely(ZsHugePage(zspage))) - return NULL; - - return (struct page *)page->index; -} - static struct zpdesc *get_next_zpdesc(struct zpdesc *zpdesc) { struct zspage *zspage = get_zspage(zpdesc); @@ -1936,13 +1913,13 @@ static void init_deferred_free(struct zs_pool *pool) static void SetZsPageMovable(struct zs_pool *pool, struct zspage *zspage) { - struct page *page = get_first_page(zspage); + struct zpdesc *zpdesc = get_first_zpdesc(zspage); do { - WARN_ON(!trylock_page(page)); - __SetPageMovable(page, &zsmalloc_mops); - unlock_page(page); - } while ((page = get_next_page(page)) != NULL); + WARN_ON(!zpdesc_trylock(zpdesc)); + __zpdesc_set_movable(zpdesc, &zsmalloc_mops); + zpdesc_unlock(zpdesc); + } while ((zpdesc = get_next_zpdesc(zpdesc)) != NULL); } #else static inline void zs_flush_migration(struct zs_pool *pool) { }