From patchwork Thu Jul 13 04:20:21 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: 13311270 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 BBCB4C00528 for ; Thu, 13 Jul 2023 04:21:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 57C498D0007; Thu, 13 Jul 2023 00:21:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 504608D0005; Thu, 13 Jul 2023 00:21:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3576B8D0007; Thu, 13 Jul 2023 00:21:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 256698D0005 for ; Thu, 13 Jul 2023 00:21:14 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id EE4801C7070 for ; Thu, 13 Jul 2023 04:21:13 +0000 (UTC) X-FDA: 81005288826.08.13C03C2 Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) by imf04.hostedemail.com (Postfix) with ESMTP id 3481040009 for ; Thu, 13 Jul 2023 04:21:11 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=miEYIZPd; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.167.179 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=1689222072; 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=ngawLjUhlg0gVz5P0h4QP2p0Jiq//HK+SFvWsbVxntw=; b=kP0PlIz3Zk9G7ZGf+gusNr/I1YtU2TI7Hfao1rA0ZjB9szdeVjxfEEEnCfhHoYnFqqwxfF s5XbnP3qE1h6AcOBChiMekOMAAao1p6WndAXQXaFfc6KaYaP67AeFCSyghko4DghEcLNYa 7D3T3wXBcjIreLjJlziPMA5vbWRp0nA= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=miEYIZPd; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.167.179 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689222072; a=rsa-sha256; cv=none; b=3ZTlCOLVYbYP400SCkYtZCy68zwcU9W5ehlWHVJGcL3TM7R0T/MFd94CD+Z8ZkLyFNeWt4 z5DaYW+VsDuBb4DQhqAIKuwSyDh3fW6Qo3xkURqtozporDsmol+9r8QMdRThgknVP+rdlB g/dMFsC4aUlPtM0/HFRXg+eHPvcLTKA= Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-3a3a8d21208so338316b6e.0 for ; Wed, 12 Jul 2023 21:21:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689222071; x=1691814071; 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=ngawLjUhlg0gVz5P0h4QP2p0Jiq//HK+SFvWsbVxntw=; b=miEYIZPddB/Lztm+8sp7zafciwuYzQBUl4vbQGbauqTEcHNn1gEDiWgi3y0NgODIfO KRfT+s1Unu3fijwGFRA6MVzyG+GUTrtnozO/iijdLuLlverMdvhbbTy4KwFmhEM5G9I5 6H4sT2yoo+nLtShyHPAgT2TLEkXkcqjkOYo5zSs8l+iYRqrwf6iFewKlwX+tu7MIZZUj uKbOvKvpFprsduIHAWTp/zGNXtqmvpQcnFs8GoLU8Q5hhYMS/VT3SNJrpvkAwpLFA2l4 hZJN2f5WCfZZdlO9fOSko+tMYv92fmCpNUo+GPxTMo2dQXPG6ljyZ6MIxVd4qMqUDoys U4PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689222071; x=1691814071; 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=ngawLjUhlg0gVz5P0h4QP2p0Jiq//HK+SFvWsbVxntw=; b=jPexaT4FMskgvsXBbDANnGS7vpf/qz18Epgxga5ga/yF9/kFVgmUFiNhRXdwha+lQG wRm29Rrhj6RrTRI2xPFqyQ3/F84a4iydetTTb/YKTgnhWB9O8aNqXW0CXDMPOlN9iew5 Zl04amN8Qnj6dopY2Ol49jYhv6lNyrA81YkC6zDHylksbos8VlHtDDPwwHJSfV0U0ito CZt819V+pkxBhiHiSaXI6orO06FkxQ+iH913R2K8hrWjWCwYkonavK3UIXrIbWaqSgE8 +xs5Av/31huEDdt1QTouOx2Ga4R5XJoALHjeK1DF8NZS2OdRofVNchl+S3HM1VZnxliX IVIQ== X-Gm-Message-State: ABy/qLYAdfRCRgGLfeQ26ICmZYX7ym91ssILro7p/Ns5r6A+w40KFtqi DQgPk8vql4V8Fjop/dex8ms= X-Google-Smtp-Source: APBJJlGDVBDJqg7HpEytgDXKLoXjRZHg1FxttzevCADnVlsFukqWkseGrbnLv60ArIu2kkBe91QxcQ== X-Received: by 2002:a54:4d85:0:b0:39e:940c:2a58 with SMTP id y5-20020a544d85000000b0039e940c2a58mr682388oix.5.1689222071167; Wed, 12 Jul 2023 21:21:11 -0700 (PDT) Received: from fedora.. ([1.245.179.104]) by smtp.gmail.com with ESMTPSA id u18-20020aa78392000000b006827c26f147sm4346601pfm.138.2023.07.12.21.21.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 21:21:10 -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 06/21] mm/zsmalloc: convert __zs_{map,unmap}_object() to use zsdesc Date: Thu, 13 Jul 2023 13:20:21 +0900 Message-ID: <20230713042037.980211-7-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-Rspamd-Queue-Id: 3481040009 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: zmaxaowwqeikys5jw73bic7hyj9xuoap X-HE-Tag: 1689222071-737622 X-HE-Meta: U2FsdGVkX1/CQNttDQCQxS0pfMvCc8nrG4hToTxLOYVKP2pLqkyo5PGGaNV6SrjSM4czHDidJG59S5TN8WisnrF2JLMhVyevgS6irpm9FyafK4H94rrhyhcB7nQGR3mOIHklRaHp5mY8hAHmaScWQt3BJav6CGSe+4iB/WyKUmIspsf1ruJTWRrW/5QBmyni3+ql+XlZMXFaVrJ4ehwG8oP/kX/3nE89gr9RdS+Hjw6wJyyiUBKqeogfHCTvQD2UBAxTOvmf3ZaW1My8Vs3KdcOboiTHNUWKGL+g1E5/RiSfJ3AafFDV/c6E5QLAkhG1qjpQBjE1kCfcKA2IdJjHWxBXfxSgapJn7Hpswp7SyNjkF8Lxa1elv3uaw6W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hke4HwX7pVAQr62ikPm6YAcU0s7lf9VUiD1p/ydYUv7YVbthMmqNgSAwZeTgsceJ9ISJiPvRNjxeGzZFLJn3DUh+v9nV703scSucx8b8LwvvUsVGTFV/5Nr6kkZ7IQ8NTsX5DUaauR4g== 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: These two functions take array of pointer to struct page. Introduce zsdesc_kmap_atomic() and make them take array of pointer to zsdesc instead of page. Add silly type casting when calling them which. Casting will be removed in the next patch. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 2cce76a19a1e..4c0563fce3d0 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -341,6 +341,11 @@ static inline void wait_on_zsdesc_locked(struct zsdesc *zsdesc) wait_on_page_locked(zsdesc_page(zsdesc)); } +static inline void *zsdesc_kmap_atomic(struct zsdesc *zsdesc) +{ + return kmap_atomic(zsdesc_page(zsdesc)); +} + /* huge object: pages_per_zspage == 1 && maxobj_per_zspage == 1 */ static void SetZsHugePage(struct zspage *zspage) { @@ -1151,7 +1156,7 @@ static inline void __zs_cpu_down(struct mapping_area *area) } static void *__zs_map_object(struct mapping_area *area, - struct page *pages[2], int off, int size) + struct zsdesc *zsdescs[2], int off, int size) { int sizes[2]; void *addr; @@ -1168,10 +1173,10 @@ static void *__zs_map_object(struct mapping_area *area, sizes[1] = size - sizes[0]; /* copy object to per-cpu buffer */ - addr = kmap_atomic(pages[0]); + addr = zsdesc_kmap_atomic(zsdescs[0]); memcpy(buf, addr + off, sizes[0]); kunmap_atomic(addr); - addr = kmap_atomic(pages[1]); + addr = zsdesc_kmap_atomic(zsdescs[1]); memcpy(buf + sizes[0], addr, sizes[1]); kunmap_atomic(addr); out: @@ -1179,7 +1184,7 @@ static void *__zs_map_object(struct mapping_area *area, } static void __zs_unmap_object(struct mapping_area *area, - struct page *pages[2], int off, int size) + struct zsdesc *zsdescs[2], int off, int size) { int sizes[2]; void *addr; @@ -1198,10 +1203,10 @@ static void __zs_unmap_object(struct mapping_area *area, sizes[1] = size - sizes[0]; /* copy per-cpu buffer to object */ - addr = kmap_atomic(pages[0]); + addr = zsdesc_kmap_atomic(zsdescs[0]); memcpy(addr + off, buf, sizes[0]); kunmap_atomic(addr); - addr = kmap_atomic(pages[1]); + addr = zsdesc_kmap_atomic(zsdescs[1]); memcpy(addr, buf + sizes[0], sizes[1]); kunmap_atomic(addr); @@ -1342,7 +1347,7 @@ void *zs_map_object(struct zs_pool *pool, unsigned long handle, pages[1] = get_next_page(page); BUG_ON(!pages[1]); - ret = __zs_map_object(area, pages, off, class->size); + ret = __zs_map_object(area, (struct zsdesc **)pages, off, class->size); out: if (likely(!ZsHugePage(zspage))) ret += ZS_HANDLE_SIZE; @@ -1377,7 +1382,7 @@ void zs_unmap_object(struct zs_pool *pool, unsigned long handle) pages[1] = get_next_page(page); BUG_ON(!pages[1]); - __zs_unmap_object(area, pages, off, class->size); + __zs_unmap_object(area, (struct zsdesc **)pages, off, class->size); } local_unlock(&zs_map_area.lock);