From mboxrd@z Thu Jan 1 00:00:00 1970 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 EB36EC4332F for ; Thu, 14 Dec 2023 18:27:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 224636B018F; Thu, 14 Dec 2023 13:27:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 188556B0189; Thu, 14 Dec 2023 13:27:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EF33C6B016F; Thu, 14 Dec 2023 13:27:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id D4BB26B010F for ; Thu, 14 Dec 2023 13:27:16 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 9C5AA1A020D for ; Thu, 14 Dec 2023 18:27:16 +0000 (UTC) X-FDA: 81566256072.11.10058DE Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by imf03.hostedemail.com (Postfix) with ESMTP id C54C320002 for ; Thu, 14 Dec 2023 18:27:14 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=HuTJZiuM; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf03.hostedemail.com: domain of yosryahmed@google.com designates 209.85.128.47 as permitted sender) smtp.mailfrom=yosryahmed@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702578434; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=bctp29PdPWOavrokHMDmcicJ81XG4ASzLMzC7oVXid4=; b=NYThH+2//M/USR6XU9NRCVw1UgS2J7bd4kqV7siUi0H9Cve7W0ZgLzofiDCwb2WIPylMh2 5Q8WZiEjWjxXsCEMMoHd6qXMgaRR3T71ByjIDM7axKP1GlbvkPM7VrWxnkRTCsZMlnYc9g ZDV3/o6rK5+tA2+47vMyDZzrjLnZ5DA= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=HuTJZiuM; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf03.hostedemail.com: domain of yosryahmed@google.com designates 209.85.128.47 as permitted sender) smtp.mailfrom=yosryahmed@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702578434; a=rsa-sha256; cv=none; b=m8DHckHVqCK1tWB2prABMGAZ3/WpYlVuHT2gwMQuCI9zyHUQnhjTeMBepHNKFjr/iDt5x8 BYq1ykDgFinUz2VL+JvZObGbJNyFYX952JCazEZhuSh2Ld2ertnwpnv0a4KbI8YaLhLOrD nD4ifUTn/NH1TG3VAHkJL7LT9XSSuRM= Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-40c2718a768so81968095e9.0 for ; Thu, 14 Dec 2023 10:27:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702578433; x=1703183233; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=bctp29PdPWOavrokHMDmcicJ81XG4ASzLMzC7oVXid4=; b=HuTJZiuMoabQhhrKzwSABEddg4NQa8GBeVp74uFVfXczA5Ko3gVhX9tTirLb2IkkJw BmLtFRNTWrq/Q9a7j0fnqG6qW6WgrcnxSEQEUSeMFbZJM5b5ORNZMA0aiCaCnofqDhpt nmmw1sCLsGBYF/c8kOzn61tDlKj8LCGKrCiKZjk7zeXNM0Xuh4eig8uo/j5XcUPTnTEd PZy8qHsrqM0O5DNJGg12DCp7n6uxt30cmEv0BWLQ0qexYwj/oqkgvbjF4qwifZdCGZof nWEAyEe924+P/4cbfr0sp7snooOf1hQcZaeNFnznHhr+i/SxNy+JZG/G79CcKv4H6hRU ze8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702578433; x=1703183233; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bctp29PdPWOavrokHMDmcicJ81XG4ASzLMzC7oVXid4=; b=GARUC0g/fIg5D49+/YE2DkE6OmovowlcXz60elBXH8jV/Al3mgVPBTbbjfQgzoqSSP QHgXJxnW9JF56vOUbbTrstyABoGwwG2AEFOVEXJosjemH1VvbJ4duQx4TCaZkWtQBzQD addeit0ArOqQJXM/55h7WkqUu6RwNJ3XEkF5mp+nb9zY+so7uCVkE/ee5d6bORUzAgYv RWicDp4gTsz+4rt/3In3zTqe73jS0Ad6FcsCDnPuOhsEsRQI04FG6D0yTj0CY4KSnWJ4 qENhuWvI72581E2u523MolgZfD+W8Kq3XE8+od2DafTLhbRzHrr7yO+m67SVTW7MvLHl Rvjw== X-Gm-Message-State: AOJu0YyzcLXio9DCDvNS1WdgGSWJEtIEGWZXkbV9hvUWEliIxS8F5ynO sRm/Z7Dg2N7zmuUB8VkRHofa59tIWQKIZTj27Py5sg== X-Google-Smtp-Source: AGHT+IFuM1IrzBEHpj38CAahCxJQyrUeHqIS/+Q/Eg9MV8lQ3OJGIKYggwJSCqalFrBMPzAhxty+4Q4RQYH8p5iWAzQ= X-Received: by 2002:a05:600c:3784:b0:40b:5e1b:54a8 with SMTP id o4-20020a05600c378400b0040b5e1b54a8mr5433555wmr.52.1702578433154; Thu, 14 Dec 2023 10:27:13 -0800 (PST) MIME-Version: 1.0 References: <20231213-zswap-dstmem-v1-0-896763369d04@bytedance.com> <20231213-zswap-dstmem-v1-1-896763369d04@bytedance.com> In-Reply-To: From: Yosry Ahmed Date: Thu, 14 Dec 2023 10:26:37 -0800 Message-ID: Subject: Re: [PATCH 1/5] mm/zswap: reuse dstmem when decompress To: Chris Li Cc: Chengming Zhou , Andrew Morton , Nhat Pham , Johannes Weiner , Seth Jennings , Dan Streetman , Vitaly Wool , linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: C54C320002 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: rfh1s5zxqdkkiwg6soatbh85p1qtkjzp X-HE-Tag: 1702578434-783552 X-HE-Meta: U2FsdGVkX1+82sFqp2kkoFXETVvGR50l1zhggCYhVruyOEIWEOhJ93TofG3DehUYh4SAEeodna4oZCOh++8yIyzlaVD9C+hSk298V5gXMLXQ2MDmOvH/8nsbeIdZrMkkAj8iP2npLzmf3hrl4iIau0c0UieRwgj9AAwAYgWu385N7dEkXDD186bcK5liqc6OagzeMZzSaH8l3H1xbYJawyx9lbA4G7qsq4YcCdtopkun9nSr+hLyC7r9VlhGtXuzySvxTrWeklmA8xmk7xIe7+WwoXwEEfzXEBdNz36lfXLm+6HnYn/Af+FBVdq95ctx959djr1xsO+dk0GM1ABG/lYhY6b2SxD2PVuiQXvqDVdgdE1URJwwYYfZxniUibQfIdQmtPs1S3W+LJ9/JQrG3YxalWWdwSOC3ohurQfys03xiOn964gu067q3thy8SkfzTQXobkmeqpQSg4LwhoK/L6ZxANwToao7o7ZBqa73QVh5Lh17c0FH5eJWVk6jsvJx1jTLQZ65yAuh98ZvabPYCC8NAOHk4T2SjjCxcyOcBlYKJyYklPMfC1FJdI8NjxCLaVeaPbyoUKrEen9tP5LXi19a4aApo9coTxHowUN/TtzojXcFDHbW4zt875AxyCYQzrVnsVHhJME3s1ywZ4u+jYLvSKFIMp/LjPgu9KUnrA+8sR1L4Xxj/bV0rHEKDCIrcthahNYkPvIhQTiXa40TsnSdDe+3KrNPe6c9MtX9oaTnU9lcIFVQNu5wsjHJPaogLey+VgBnfS9y3OcM2sE3axL4c8Bo2210clcbNY8byxrLhO3j/ejyxPaFYRihzhZVLoOR3NSPhiHfkkrHe3gqwctWeGi9IWJe8U4sCxjOmwO4AGTg/gE0+OsnEqbiLPVqHmzoW6F3pBrPcGq+j+Ch2I9sD4CQeup4zVzbAp3FZS3pKQbmMFHts/wfI9RnxckwsVwe4lQYV7e4MAetIe 4O7f8rfF eQGJkyKMY2GVOXxfF1H8XjaxD6FtbSNhA6zYLV6vr6cOjmyiZ4JwG5J1aLr6BnJDnwU2vDvpcHQziqujwRuKmN4+Icm1F853yfC0kPDe05nmdOw8gJ9plkeS4Mjf28YJ1AyBpyTphY55NMrO8Oyx4oEiuO8phpf1Uj3mmC9nPVAiCJxCt7XuOvKWQopZU7JtIhAY7n1s28JOD9rjADe5HbeLmCfj8h3Y78kEM/urD8HuFP/mypUBE+dLTowXXcUh7o8wgNbJT8oOQp5MxI+mWkg59Cas6Q0xB1epYixUK5RxPpxdnS2HfjJWhhG1gM3+A6PXrudlCyNvBR7Cov7JNnLKRNQ== 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: On Thu, Dec 14, 2023 at 9:59=E2=80=AFAM Chris Li wrote: > > On Tue, Dec 12, 2023 at 8:18=E2=80=AFPM Chengming Zhou > wrote: > > > > In the !zpool_can_sleep_mapped() case such as zsmalloc, we need to firs= t > > copy the entry->handle memory to a temporary memory, which is allocated > > using kmalloc. > > > > Obviously we can reuse the per-compressor dstmem to avoid allocating > > every time, since it's percpu-compressor and protected in mutex. > > You are trading more memory for faster speed. > Per-cpu data structure does not come free. It is expensive in terms of > memory on a big server with a lot of CPU. Think more than a few > hundred CPU. On the big servers, we might want to disable this > optimization to save a few MB RAM, depending on the gain of this > optimization. > Do we have any benchmark suggesting how much CPU overhead or latency > this per-CPU page buys us, compared to using kmalloc? IIUC we are not creating any new percpu data structures here. We are reusing existing percpu buffers used in the store path to compress into. Now we also use them in the load path if we need a temporary buffer to decompress into if the zpool backend does not support sleeping while the memory is mapped.