From patchwork Thu Nov 30 10:12:31 2023 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: 13474207 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 CE9CBC4167B for ; Thu, 30 Nov 2023 10:13:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 631C56B0468; Thu, 30 Nov 2023 05:13:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E0AB6B0469; Thu, 30 Nov 2023 05:13:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 481686B046A; Thu, 30 Nov 2023 05:13:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 346466B0468 for ; Thu, 30 Nov 2023 05:13:32 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id EC8951A0105 for ; Thu, 30 Nov 2023 10:13:31 +0000 (UTC) X-FDA: 81514208622.20.C4900E4 Received: from mail-il1-f182.google.com (mail-il1-f182.google.com [209.85.166.182]) by imf19.hostedemail.com (Postfix) with ESMTP id 0EB841A0014 for ; Thu, 30 Nov 2023 10:13:29 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=EGeIz0ku; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf19.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.166.182 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701339210; a=rsa-sha256; cv=none; b=SdM3K2rhOO1Kvz46wy874EYP4AXKOpGW0G05j4GOn2b7BqFN33nZxdBOEFdwtWbRiP5pGz uv3e6FgnvIi0xmuWmYi/wLyTVmnzz80kvDLJTe7U0SX5Mv5VDBKsU8I+L7WZSdcSJJbh2b kAYU7QFYlJ1oURQQFCUTcQu0ZWV+5gM= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=EGeIz0ku; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf19.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.166.182 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=1701339210; 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=Alm4Uwmfg8k4l9xZX4lYF39z1/lXjIuceVYYdGDrSHg=; b=TwAuw3ph+jFwMS2NmIfu6tS9LddXqf9qKQIwWLqwl2JrzcaG9f3ukUXF1PIqIyVhgPRdRf 5e4hOZ2+HuKRr0th4VK6s7mQ70CbOAh+AsVgk0reWJl0QLmprt2PVDTusKZUp1txo8k5qc 7Q2/4XQ6kCYTwuqsrK0Bzy5Nz2UZ12E= Received: by mail-il1-f182.google.com with SMTP id e9e14a558f8ab-35c690f6e00so2023785ab.1 for ; Thu, 30 Nov 2023 02:13:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701339209; x=1701944009; 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=Alm4Uwmfg8k4l9xZX4lYF39z1/lXjIuceVYYdGDrSHg=; b=EGeIz0kuxpSPcUcYyHs3jcKCeajNquzfMc9rptYy/UZjmtfRPBT21RQyE+peDt3q+W /0GIsNNYQKNRDiacfNC3RxnOi8GgicmU+DO4z1hAh/RQYzHJXKssn/AUewj5JCiW4uIj 1X8JaQ0GhW7Z72aiHEzYfQnqyIsuiLDTTjXo+YuHOanwuavWGHMyp9pfz4zBn00RaKsp HY4js4LtmMzfIMWWrGdg1SYQQaZCvdRp/3WUm4KAyEMEVb3lSFev9Bxv/0C9zgQXsZoj s1lOloDS80LSDKjJdxaSRRFdAzwc1gkgW/SepwXYpIpXBUtBq2QO0WAMofkwZlw0qDmy UUow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701339209; x=1701944009; 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=Alm4Uwmfg8k4l9xZX4lYF39z1/lXjIuceVYYdGDrSHg=; b=TF/esbt/vEV+JU03K4gVw36N1Llq0YaTTuLdxlJ4WdOzLTzNLmwm3WEwt7ihHpxiyW U/D48yVXLb8fcJ7+RWfLiFGZD2IChqWAN20xop8ErVId6+30lpDOiNEaDBviPozjdROD vxb5D9UkTb6sxv385bwqII+kZLlBg877LBzYLSWr1aWg+cY4O9uUYd6Ku+2jJcVjvUL0 WC23esn4uCf2lSB+voTJVuNaJmNPVvpRXMGw6UsmFuofqdYWu/1dzIqyqjplziLM6fS+ EjeHhBvMHVutF0kYinASaE3Z+H2jvCb/iqeHo6w+IichKv7Bw9SAzrfRphkXIBnm8O1M CifQ== X-Gm-Message-State: AOJu0YzAD4oPPGRgNVf/idXUlAIJ8dwjasUNwChbGFpt5iJ4dupGBnni V/lY2BSIHlgA/tmh0z/BCkY= X-Google-Smtp-Source: AGHT+IEkldX3LH8USjAq6RqcqBA9mVaJhfibAPk/CkQLar7kV7XzoLuUQo1kmMTNe3O+LbfKqEuT+w== X-Received: by 2002:a05:6e02:12c1:b0:35c:c916:892b with SMTP id i1-20020a056e0212c100b0035cc916892bmr14929126ilm.4.1701339209129; Thu, 30 Nov 2023 02:13:29 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id r27-20020aa78b9b000000b006900cb919b8sm841402pfd.53.2023.11.30.02.13.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:13:28 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Matthew Wilcox , Mike Rapoport , Yosry Ahmed , linux-mm@kvack.org, Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC PATCH v3 10/21] mm/zsmalloc: convert obj_allocated() and related helpers to use zsdesc Date: Thu, 30 Nov 2023 19:12:31 +0900 Message-Id: <20231130101242.2590384-11-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231130101242.2590384-1-42.hyeyoo@gmail.com> References: <20231130101242.2590384-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 0EB841A0014 X-Stat-Signature: xc94fnk6kgmre48as73fjn9gq4mwpghg X-HE-Tag: 1701339209-145730 X-HE-Meta: U2FsdGVkX1/apu7tJKptN4UfKVn0RXlaL14E+qcYlhQdZrhJJSd+r6YKxl3seNyQeBBpbWVsPsUy9UF5IqoXNo391HJvBNflLUMvS67AJBblc1nP6yDVxZbD0LGJGdqksw8qC8SGHM4vrPcfwOwIIiaKOMwNK1vYvbFbxJYPz59gguasFU06GjoQHl5IJD3IqP1jvyimXetOK6h91HMKVhVPejj6AjXHbUNKz08iliGNIYX8vh2KzLdnAVvI5HLsgbDMOKcLXwO2Bmtf7lRrh0mu4aM+PKFYW5lj3aIXQ3FKWzwfCk1FA32x1ahC+Vf7mtWC5K1nGF38bWsdIlneiflSKsCY8AQXWH960dd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DIFkpyOkge3jhnjL5DFmEpxhfq+oackMrAQnzZMr0RPcLHAN2BDjY5XFCKHxUr98hE2+6pqIIcUGypMLxz3RAJuGau3I5Uzz6g0PBk5WZ6KoeyAjSjRvhbb+e9SAzq5pOuNnu7k+d4sa3vWUd7OO06MH0XcPdA5k36Ty8d3rq/ZVbC8N7CddKhh 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: Convert obj_allocated(), and related helpers to take zsdesc. Also make its callers to cast (struct page *) to (struct zsdesc *) when calling them. The users will be converted gradually as there are many. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 1b5b9322ec21..f625d991bab1 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -946,15 +946,15 @@ static unsigned long handle_to_obj(unsigned long handle) return *(unsigned long *)handle; } -static inline bool obj_allocated(struct page *page, void *obj, +static inline bool obj_allocated(struct zsdesc *zsdesc, void *obj, unsigned long *phandle) { unsigned long handle; - struct zspage *zspage = get_zspage(page); + struct zspage *zspage = get_zspage(zsdesc_page(zsdesc)); if (unlikely(ZsHugePage(zspage))) { - VM_BUG_ON_PAGE(!is_first_page(page), page); - handle = page->index; + VM_BUG_ON_PAGE(!is_first_zsdesc(zsdesc), zsdesc_page(zsdesc)); + handle = zsdesc->handle; } else handle = *(unsigned long *)obj; @@ -1702,18 +1702,18 @@ static void zs_object_copy(struct size_class *class, unsigned long dst, * return handle. */ static unsigned long find_alloced_obj(struct size_class *class, - struct page *page, int *obj_idx) + struct zsdesc *zsdesc, int *obj_idx) { unsigned int offset; int index = *obj_idx; unsigned long handle = 0; - void *addr = kmap_atomic(page); + void *addr = zsdesc_kmap_atomic(zsdesc); - offset = get_first_obj_offset(page); + offset = get_first_obj_offset(zsdesc_page(zsdesc)); offset += class->size * index; while (offset < PAGE_SIZE) { - if (obj_allocated(page, addr + offset, &handle)) + if (obj_allocated(zsdesc, addr + offset, &handle)) break; offset += class->size; @@ -1737,7 +1737,7 @@ static void migrate_zspage(struct zs_pool *pool, struct zspage *src_zspage, struct size_class *class = pool->size_class[src_zspage->class]; while (1) { - handle = find_alloced_obj(class, s_page, &obj_idx); + handle = find_alloced_obj(class, page_zsdesc(s_page), &obj_idx); if (!handle) { s_page = get_next_page(s_page); if (!s_page) @@ -1996,7 +1996,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, for (addr = s_addr + offset; addr < s_addr + PAGE_SIZE; addr += class->size) { - if (obj_allocated(page, addr, &handle)) { + if (obj_allocated(page_zsdesc(page), addr, &handle)) { old_obj = handle_to_obj(handle); obj_to_location(old_obj, &dummy, &obj_idx);