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 E388BC433FE for ; Thu, 10 Nov 2022 22:25:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5A8106B0074; Thu, 10 Nov 2022 17:25:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 557818E0001; Thu, 10 Nov 2022 17:25:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 41F1B6B0078; Thu, 10 Nov 2022 17:25:38 -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 338366B0074 for ; Thu, 10 Nov 2022 17:25:38 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 07CEA80C97 for ; Thu, 10 Nov 2022 22:25:38 +0000 (UTC) X-FDA: 80118965556.01.4C9DC26 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by imf03.hostedemail.com (Postfix) with ESMTP id 9F4FC20002 for ; Thu, 10 Nov 2022 22:25:37 +0000 (UTC) Received: by mail-pl1-f180.google.com with SMTP id u6so2710228plq.12 for ; Thu, 10 Nov 2022 14:25:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=W47FD2a5xAe7nFqoz3Hz5sg2zfn+k9i0H3yNcGRFzH0=; b=fDROxbevb7z5jJz0NSNvAnBoNC1ZqC8s11YTdaOtbMg16ItiORRyT9i2n/pxJmdec/ gf+LwJgxGlV/ePtI6PCnJdVK0zWT2xd28cNmllkF9p/U4//MfEwWg4PZEWUeZtUMyEpx UnoHLjYUsM8WgOAHfnj9OPLFJfCJF/n/kB13nir+CDFoDdlCm8vtGQDvMmeLEK8GJ7jx qdIqyjen7XluJkO0DaYzWSY/WvfCQHjXK3mhY0cgP1kNg/UC/dkhRlkfI3h5QxyEg8+i nFhKinzVJ5qvfi7aECKEYgz7S0yshUOIzD/0kuI21fNDNeZEojPv17hzDvrp+YeZs4CL 1ONA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W47FD2a5xAe7nFqoz3Hz5sg2zfn+k9i0H3yNcGRFzH0=; b=WkCq/69N+MkSlGYL3m78aMHFDiEVuKNFj7LCN8uNCmYl5yOV7NojmdmvjpPiG14ENk mPyHxItjzQaNovEE9kK38hccMsEt9rEW3hzViJ2fV/BG1IwjZiL8My0UwibhMZMw6FSA tl+hMNAy/IZA+TmxpVYIMeDhaLqctRRy57UCo70IxoH3APwxoqh7OLLjAotNbYx3St+X 0suv06JjszYe05w2BSHJFtRGnvbIHdd1HpWcPVouBQxWU5QyKjiit1HOTUqltxUnaG6v 6b3wcI2izNlBONZwEGn8XiSbGyzZkl+MrCGMNRhGo92LGhm3bKg7W+ePQt+f7NsttKBd tWPA== X-Gm-Message-State: ACrzQf3a5LcoFV6VO+A0OWlG/LnmEmOx1b9yMQ1YiT67MJa7A+tBGwcy /VNNYyMl7LN6IYaJig9sUCk= X-Google-Smtp-Source: AMsMyM70GK/pwQgFUBDgUO0VohqQWUqOs0IfJFQpXfFaPhdMxW6ffuk/Byzir7EVuLff3Bi/bWoZAA== X-Received: by 2002:a17:902:cf09:b0:172:7a15:9a61 with SMTP id i9-20020a170902cf0900b001727a159a61mr2313024plg.71.1668119136626; Thu, 10 Nov 2022 14:25:36 -0800 (PST) Received: from google.com ([2620:15c:211:201:8c0b:3260:c81c:119d]) by smtp.gmail.com with ESMTPSA id nm13-20020a17090b19cd00b0020087d7e778sm3562899pjb.37.2022.11.10.14.25.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 14:25:36 -0800 (PST) Date: Thu, 10 Nov 2022 14:25:34 -0800 From: Minchan Kim To: Sergey Senozhatsky Cc: Andrew Morton , Nitin Gupta , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCHv4 4/9] zsmalloc: make huge class watermark zs_pool member Message-ID: References: <20221031054108.541190-1-senozhatsky@chromium.org> <20221031054108.541190-5-senozhatsky@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221031054108.541190-5-senozhatsky@chromium.org> ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=fDROxbev; spf=pass (imf03.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.214.180 as permitted sender) smtp.mailfrom=minchan.kim@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668119137; a=rsa-sha256; cv=none; b=c8eBJ5Jn8xDvuLEDy2Z4CVwgdwplNfAUwYKH1BX2r772RAgPVw4w5NdOLg6MDwx4xCU/H1 hEtPrhvC/eztZmPHLmPBgKRmq0AKKt9iiFz8v0ukq8fx4Nsu6RxJOv2DvKcVrJ+7Wi8LMm /CWAT4/pgOsgH/oMWmc216D+2c4bBrk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668119137; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=W47FD2a5xAe7nFqoz3Hz5sg2zfn+k9i0H3yNcGRFzH0=; b=uK7b3PKdeCsgwh9k7Uwh4WQFgXfovx9UhpUuFVEeDDh7sKNFhZa8b5sHrIsW29DIy+J0zv NibD4FGlG6H8BGQg1wGrKqeTDhCTefv5TxJdEuFCLqN+oKqOKQma/dGZMMFMZ+7nLuMeHl KOMufTXG8SJwx5q3Y9vo9pvZq/TRpFw= X-Stat-Signature: 5sb1747k6me1ccnzzoboaou7w47fhm4a X-Rspamd-Queue-Id: 9F4FC20002 X-Rspam-User: Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=fDROxbev; spf=pass (imf03.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.214.180 as permitted sender) smtp.mailfrom=minchan.kim@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) X-Rspamd-Server: rspam11 X-HE-Tag: 1668119137-885538 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: On Mon, Oct 31, 2022 at 02:41:03PM +0900, Sergey Senozhatsky wrote: > We will permit per-pool configuration of pages per-zspage value, > which changes characteristics of the classes and moves around > huge class size watermark. Thus huge class size needs to be > a per-pool variable. I think part of code in previous patch should move here since you are creating the feature in this patch: BTW, I am wondering we really need to jump the per-pool config option over global general golden ratio and/or smarter approach to optimize transparently depending on how much memory we have wasted. > > Signed-off-by: Sergey Senozhatsky > --- > mm/zsmalloc.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c > index 5f79223e7bfe..d329bd673baa 100644 > --- a/mm/zsmalloc.c > +++ b/mm/zsmalloc.c > @@ -178,7 +178,6 @@ static struct dentry *zs_stat_root; > * (see: fix_fullness_group()) > */ > static const int fullness_threshold_frac = 4; > -static size_t huge_class_size; > > struct size_class { > spinlock_t lock; > @@ -227,6 +226,7 @@ struct zs_pool { > > u32 num_size_classes; > u32 min_alloc_size; > + size_t huge_class_size; > > struct zs_pool_stats stats; > > @@ -1350,7 +1350,7 @@ EXPORT_SYMBOL_GPL(zs_unmap_object); > */ > size_t zs_huge_class_size(struct zs_pool *pool) > { > - return huge_class_size; > + return pool->huge_class_size; > } > EXPORT_SYMBOL_GPL(zs_huge_class_size); > > @@ -2262,8 +2262,8 @@ struct zs_pool *zs_create_pool(const char *name) > * endup in the huge class. > */ > if (pages_per_zspage != 1 && objs_per_zspage != 1 && > - !huge_class_size) { > - huge_class_size = size; > + !pool->huge_class_size) { > + pool->huge_class_size = size; > /* > * The object uses ZS_HANDLE_SIZE bytes to store the > * handle. We need to subtract it, because zs_malloc() > @@ -2273,7 +2273,7 @@ struct zs_pool *zs_create_pool(const char *name) > * class because it grows by ZS_HANDLE_SIZE extra bytes > * right before class lookup. > */ > - huge_class_size -= (ZS_HANDLE_SIZE - 1); > + pool->huge_class_size -= (ZS_HANDLE_SIZE - 1); > } > > /* > -- > 2.38.1.273.g43a17bfeac-goog >