From patchwork Thu Nov 30 10:12:27 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: 13474203 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 C25C2C4167B for ; Thu, 30 Nov 2023 10:13:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 460C96B0460; Thu, 30 Nov 2023 05:13:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 349AB6B0461; Thu, 30 Nov 2023 05:13:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C3086B0462; Thu, 30 Nov 2023 05:13:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 01D596B0460 for ; Thu, 30 Nov 2023 05:13:20 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id C830EA014A for ; Thu, 30 Nov 2023 10:13:20 +0000 (UTC) X-FDA: 81514208160.29.A4ABF3B Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by imf28.hostedemail.com (Postfix) with ESMTP id E8010C000F for ; Thu, 30 Nov 2023 10:13:18 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ao710wkc; spf=pass (imf28.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.169 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701339199; 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=GZ5+k+xZdrGcARQj7U5lpnB1y/2JIFVjU4+7cRgD1WI=; b=WKwbGsVQfaqZLSqycsNusNdR6p7pUaVAuzzLq4QAJtA3Tb0Z7qA3iQ4K7rMjnQHO/H5DpW iFo/NiCXJi67MVxt5PW2Wt1+iTfKDi2OFrrByIc4Q+11Pq2dWPE/THc5i1SpjSckXMoo9C Da+76nKxh1TcYBTHfLooB/izH25TfFw= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ao710wkc; spf=pass (imf28.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.169 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701339199; a=rsa-sha256; cv=none; b=N7OkQVo5DnKLZInkKRQytczHi2+WIMfsisjYHhGJSenp3w1Djqs7loKoijnPUZtbAuqj/N WAwsxdXQz4MV7d8M/6YFA6b6x9DcvUApYdYBciZNfStr/b+vNeY+ZcaylafSqxFCf4QU0i 1LUt4C0vin9lusIlNlpjYjceQwIU+0g= Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-6cdcef8b400so760900b3a.1 for ; Thu, 30 Nov 2023 02:13:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701339198; x=1701943998; 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=GZ5+k+xZdrGcARQj7U5lpnB1y/2JIFVjU4+7cRgD1WI=; b=ao710wkcLwTsthlBayTXcSskV1BH/9WZifwW7+k3ctdzxQLh/eGIWiEX84yrR8gE7v MGSBcGARhTKpBKgWcOpMvTReDV85ZVTvnFhgyDv9WRFIDxW2GS0YGAOj55AB2ERLKU7o hAw3eCNLA4cLAIRy9pDGICbt9kSVX4yuXseKtGuhadPUpg7BADHefc51sgeHfkGRxrfJ uh+0vsb/RGt9TtLth5kwTg/O5vvX1nLt+X2EYmm80iyvBaniVe+4LZZ9/IGYqxzzs7kr VzOsipYjOcz/Q+6Amr1QQIjw5C0MiH/tt7QgXoa4UchKTWP1tuIX36ck09xDfr3L+JvC VMow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701339198; x=1701943998; 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=GZ5+k+xZdrGcARQj7U5lpnB1y/2JIFVjU4+7cRgD1WI=; b=ESMUuR9G6WubDqw0CmP1X43WCNXopkSpnQNOoNtEKD24CyPc7UNSadZj4uANZEsXbZ eK4Fxnx4m6+86Xkmu6LcpXvKJD70lPi9qJ5s26OmjoCUvW/aKWZi7fKtb5eNUautc/Dt I9OZPRxoyiXIEHB9tkqzqUm7oM6GwjzNE53P7XAku7tkRX/l9IOAutA2Bfw0cO/yMJIB Q80f7LVJjun7GFZwbKaMDZXTaV7Q0zao0JYqy7Sp5zSc5HmBlyv5A0GSwu48jrgtOvjH 1CHR2Z9K9qVvCijNsmhqAXFw5O4C+AnCm8EIxQGVKdCusX1inR6SdT/O8WtiC6A8x5ei hMIQ== X-Gm-Message-State: AOJu0YzHthzHMVcqOycogrIUhlmQ8suOBl7NB/I8OnK6EvVf8VZ2Hw9I at6Ngk+S/uZojnkvL3JEXRY= X-Google-Smtp-Source: AGHT+IFqBPVr7Dm/UF0I0z1hPcAYdJfS/T9vLKX1SN/kDJaPGokzN6o6Gk8be2WPH7/E0wIcjljZZw== X-Received: by 2002:aa7:9a49:0:b0:6cd:d0f4:cd3c with SMTP id x9-20020aa79a49000000b006cdd0f4cd3cmr4494832pfj.23.1701339197684; Thu, 30 Nov 2023 02:13:17 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:13:16 -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 06/21] mm/zsmalloc: convert __zs_{map,unmap}_object() to use zsdesc Date: Thu, 30 Nov 2023 19:12:27 +0900 Message-Id: <20231130101242.2590384-7-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-Rspamd-Queue-Id: E8010C000F X-Rspam-User: X-Stat-Signature: ufg643icta1wgtcwne4sk4xuycnkkd8o X-Rspamd-Server: rspam01 X-HE-Tag: 1701339198-295513 X-HE-Meta: U2FsdGVkX1/ZvYyEW+tKAkIlBah/NtabrDddG7izn/waazY36Qm5x2bJ1vzTl04wGz9ZeeKtDfVPLb1B7RZf+m4eCBgDbpO1cnjafIg94WRu1NZGZX3D/yJHAUPRw4S3LjYII+cuA1rHF07IWOt3xvxdWKuCnEnpW0Z84DKkL6R/7Wd64NkwWzvq30ZMD8JMEfOIrMgnQKKihywiY1FzzpepVPYkkULNQCCQYie63GUeuL3UEnR14mYT00OBsZYSTi3KrR/HQzrtP272T9aNldi7VHP8mMb/+1aJZFS2R2udWlk8C8ZRV7hBOnaxbWBpS2yDPRC4p+lBuDtY8/NGnaxO4VMAVwsrZ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e2IfLBOaXN1aQdeH+jZLvHtbHGboMqeeFaAfMXB/YUjtC40xWvLXT68vIyAW4KwQLMAlyOrCy3KLEJ+ZVsJWFtgC5FCO298aC8ZhzFoynz3h1Ji4QUVbTPoAIbnxZpKYV2yvF3g10VYMvrIeG+J7kxLg== 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: These two functions take pointer to an array of struct page. Introduce zsdesc_kmap_atomic() and make __zs_{map,unmap}_object() take pointer to an array of zsdesc instead of page. Add silly type casting when calling them. 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 91fccc67185b..be3b8734bdf2 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -322,6 +322,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)); +} + struct zspage { struct { unsigned int huge:HUGE_BITS; @@ -1155,7 +1160,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; @@ -1172,10 +1177,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: @@ -1183,7 +1188,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; @@ -1202,10 +1207,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); @@ -1346,7 +1351,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; @@ -1381,7 +1386,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);