From patchwork Thu Jul 13 04:20:25 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: 13311274 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 8993FC001DD for ; Thu, 13 Jul 2023 04:21:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 26E118E0005; Thu, 13 Jul 2023 00:21:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1F8B08E0001; Thu, 13 Jul 2023 00:21:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 098158E0005; Thu, 13 Jul 2023 00:21:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id ED7398E0001 for ; Thu, 13 Jul 2023 00:21:25 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id C3B28A0101 for ; Thu, 13 Jul 2023 04:21:25 +0000 (UTC) X-FDA: 81005289330.20.D1835EF Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by imf26.hostedemail.com (Postfix) with ESMTP id 00B5F140017 for ; Thu, 13 Jul 2023 04:21:23 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=J0aXa+kt; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.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=1689222084; 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=ItG8ksrwK8WHStX9MB/fUTZvwyuLsvIlM15e1efhXFY=; b=wErU01sU3gfiTCRbnAWCaGuTIF15jp5/N0fbb23VDVR6kenk4UMpSAAinh5AezGxDv5Krh zD0Q1jnrlBm8Pz86G7L/pWql+s1E/8R3FJlvySWWmZiseIwXwD8YOZq63eF9OsAtz55P+y MGROOfejJftiikXCuJB7/gimi2SrAmM= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=J0aXa+kt; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689222084; a=rsa-sha256; cv=none; b=KZVVFDycFdPin26qIG4K7errm5eK433MUuCphGITm0G7x0zHc5qBbeJ0ToFtyz8jbydVlP e/s2e+msRpeoi5MRREoqZFFRBIRo4fkCXrHvQV2K8jOSF9liVCMqFS7Ry0v358WAyww+8C +nZkWo7pHLXodunoT/ozdhAOWfbXi+U= Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-6686c74183cso323136b3a.1 for ; Wed, 12 Jul 2023 21:21:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689222083; x=1691814083; 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=ItG8ksrwK8WHStX9MB/fUTZvwyuLsvIlM15e1efhXFY=; b=J0aXa+ktFUJkOdgZrLc2eH6P3UkQshHs83zm1+lxcabnZXxw2S3zbeIJMrU5IqnQpz 9OWtyPzFeDJ4eBoHQ5EtdlGXLMuCMCuJ8hWmDjHw3Uq+mwo18ozEHn2PrQm1PwV3zKQQ oewcfr0RJEamddaDOUGXzRu7FE+s2Eos0q//ZjWC5KNiJlFWWdXzJuhRR8/St6pZAkdK XLqCjS/iraG+Go+7sFNvQk18yZkdFi53LwyuJns0hwEG6WlIUi7gf2eN/K3k1WI9sz+x YYH3R2RtRgQq6xMHMd9aTAiq4LdFyBW1/+DSz99YmQKagn19cx4MSPATRiNhSbI/I0ag 2gRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689222083; x=1691814083; 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=ItG8ksrwK8WHStX9MB/fUTZvwyuLsvIlM15e1efhXFY=; b=EHiV2SqpG4Ehu3LLKGzbK1WGU9TNAwpndQy7D6F8k7rugIf+PDUxdZjtxQ/a3jEXpq LC/JbppR9qlTu4UCpWyoHj6f+oz079WZF2O/tVsIpQvQhCv0Agisrwbj8ac8N7woSIop 3Xqxfg2w0tNRNEjx93bCPE8MTh43O1qF6YzDSjQl0yrVIMLDi//yuVVBpzJLxtHUSqCM K+n8pq/euKi6ncWxCxzoldrwyftkebUCapomVWhA4Og2+u9hvfHzrC5caku/q6O1a638 2svjSG/NYOO7s8S1dXEdXvtOo16qe1AMxtnmkXuG/VVoL1Tvd/1PqD7GwCNHNPlbGJ8r pfqQ== X-Gm-Message-State: ABy/qLb99y07Lkv+qCTbI2WkhXejXvNfxTAjjyppYRIURHjG+muPWTfr prS+PlID898HXSxqgBGQp18ECg7u474cBMMHEZUlJg== X-Google-Smtp-Source: APBJJlHv1tRh9q0qQqBjcFbXSS+jcB852joeQND+bRafSNcpiomPGfwhEemort4fhA+14tH0PTb7cA== X-Received: by 2002:a05:6a00:ac7:b0:674:6dd4:8337 with SMTP id c7-20020a056a000ac700b006746dd48337mr934769pfl.12.1689222082858; Wed, 12 Jul 2023 21:21:22 -0700 (PDT) Received: from fedora.. ([1.245.179.104]) by smtp.gmail.com with ESMTPSA id u18-20020aa78392000000b006827c26f147sm4346601pfm.138.2023.07.12.21.21.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 21:21:22 -0700 (PDT) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Matthew Wilcox , Mike Rapoport , Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC PATCH v2 10/21] mm/zsmalloc: convert obj_allocated() and related helpers to use zsdesc Date: Thu, 13 Jul 2023 13:20:25 +0900 Message-ID: <20230713042037.980211-11-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230713042037.980211-1-42.hyeyoo@gmail.com> References: <20230713042037.980211-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 00B5F140017 X-Stat-Signature: atzdphojnse5u9n9jps354zda98dwn7t X-HE-Tag: 1689222083-215168 X-HE-Meta: U2FsdGVkX1+iVcFCa3HYGbH24flaTnLuvq62hJ/6IrIzYag+oV+J4RWkUH3+Zm9YDf4wjUn0VG34x8pJ2/UEf+Zo4EF5U5SIbVNoXSQ63c4hAIxj2SGmdNnPVELQFVs8P1iLVJ8NbukQZNmaeUa/Jl9RXii8NniF/Rr/v2py1aFTDQzWH+kpUefDBGKBnc8Ya+Bm5mVIA9HhRG/Q5L5qciI+KPA02SbnowFiNxkYCoDDe9O8ojqTcke4NuYmpNOfUvyZCRNsZKbihrxDKQD6EK3OvX368VwdRF3XT6uOTEdxaaSwHsIxgLoVcpgFlSpLA62UqHOtsZmPhBu3+K52vtux62pVL+VYetLoso44wW96gXqxTiK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jPSdTXf0qADe3Rrq51aWUBt9+RoNgQOH4lsaYwDdMlGzC5hJzfDCtcwIKOHmdE1n/w7vr8RglWuxeZNIaDnLZksAO8dFjLLC26N6QIcWCxeef9VetafeEV/c3Qc7S9FNzAyiXPAlEqc6rjCA9Aqzmetjjmu87lJ/PRmEQoWJj1glWXM4RJHL6Hp+R5xYCGQ== 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: 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 48bfdbbe3b1e..efd7a0f78962 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -942,15 +942,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; @@ -1698,18 +1698,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; @@ -1733,7 +1733,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) @@ -1990,7 +1990,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);