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 99E78C64ED8 for ; Thu, 23 Feb 2023 23:09:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B28EA6B0072; Thu, 23 Feb 2023 18:09:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AD9C86B0073; Thu, 23 Feb 2023 18:09:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9A1BE6B0074; Thu, 23 Feb 2023 18:09:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 8D24B6B0072 for ; Thu, 23 Feb 2023 18:09:38 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 5C83B160659 for ; Thu, 23 Feb 2023 23:09:38 +0000 (UTC) X-FDA: 80500100436.02.CB20178 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by imf03.hostedemail.com (Postfix) with ESMTP id 7F8C220006 for ; Thu, 23 Feb 2023 23:09:36 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=S6kS+0hz; spf=pass (imf03.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.216.42 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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677193776; 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=dbpW+ci7vAAbVs11HVGBMJ2nIWBV8zhBVEdP65zp1Mg=; b=FRqihMVyrE7m2dP/yj0+120YYbXr/b1+H49GddJbID6johO8c0+g6v1KFrbC9NCuOfHCTH GkpfJXGLdktl58I330TFb6W/JTRsOdUUMi0R1sAwVW7C7v3CU/y1yvqgC4SHHM2+/aqs8Z DbjOxHorJ0GixJjKLP0jQVNUwNRKMAE= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=S6kS+0hz; spf=pass (imf03.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.216.42 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=1677193776; a=rsa-sha256; cv=none; b=qm2ZgY98ATktln6KQNivExClz7ozQEilYfoJtvIN395rIWRnbSnWVYLCJNzvzkPpCk7oh9 W+O4pZxHfw61TmIexXucaWmwoxqtr7KWIBq8q8qTqSe5u6sD+Rdo3ec0HxYqv2oWd9zjFQ RM4Xe0isZJSmrPDWFYgtGMdIg48uH+E= Received: by mail-pj1-f42.google.com with SMTP id x20-20020a17090a8a9400b00233ba727724so4945700pjn.1 for ; Thu, 23 Feb 2023 15:09:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677193775; 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=dbpW+ci7vAAbVs11HVGBMJ2nIWBV8zhBVEdP65zp1Mg=; b=S6kS+0hzuWSn3ITuRcHTXU3ATnsL2V4jyhKhHnc+kf8eukn6OSfPKFUIQErz7NSro2 aQuwsbnxvrKpUWa6d7AM1dwe88+QR4x6BMrJlnxiFQnIxThz3OBVCd3PO2P7hVo5cvhj sa3BzF+QimwRRNhyGHDIlTQk5jujfAhu8KFMWlXWLzCPglu+780Qb27FXGC3ydZUssBz FGk1/479vVsxchfxbC8FoOtrppS2qivD2QhkgFhT+lgj3GqSqVVSF8OzbGGpmDlU73XS o8vFf4uNes+PL4Cj/bzv0ZM49798EASOL7OF3M3zJc4C39DnG2B2bmqil58GdPbrqO7u 6Z7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677193775; 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=dbpW+ci7vAAbVs11HVGBMJ2nIWBV8zhBVEdP65zp1Mg=; b=BiHNgAsDsodLEA6Jsx34lsDL51vGw9v2B9QvKiQNyaWV79UpBW6ji5iMbtPoJcH5Gz XwbUU0SrKjq+7x5sjb2eka/d8BPalZuE3VQIHIwCAWO3d2j3H++kWKGc+JZ0BISauLVB daXVTX4ot9FamVEATnWoXYbwjTSnO6KyavATIPoR98xg3c1y7c7Q3RjjRTi+Dz7fjoH5 2IxzY1gbC0Xa41XkBtWmwSmb49WPxe9B688CnXXsPLIMXiMiFwhPGeVapJQ6NYcy+e7V Nau4xCpCsLuOAre6dRCpzhNajRdJ6kW578sOBryn0Nr3H7gd10ApgF4RWy4ipBcqal4K cU9A== X-Gm-Message-State: AO0yUKVTGOEnlaAuWyt6P5WLHsc18aoym36oqxSSxTGctutU5RjNQ9Ah EyjtSE4dPEvdCIA12fMS0rc= X-Google-Smtp-Source: AK7set8br1StPmJ6VLNmzpS9FfvB+x0aTOgZ56stNNaaMSPtzCyZcFKOAK3YPZvPz5kOxTh6Pxv1cw== X-Received: by 2002:a17:903:22c8:b0:198:fded:3b69 with SMTP id y8-20020a17090322c800b00198fded3b69mr17180677plg.53.1677193774909; Thu, 23 Feb 2023 15:09:34 -0800 (PST) Received: from google.com ([2620:15c:211:201:be5:a687:1e9d:ec53]) by smtp.gmail.com with ESMTPSA id x3-20020a1709027c0300b00186b69157ecsm3419109pll.202.2023.02.23.15.09.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 15:09:34 -0800 (PST) Date: Thu, 23 Feb 2023 15:09:32 -0800 From: Minchan Kim To: Sergey Senozhatsky Cc: Andrew Morton , Yosry Ahmed , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCHv2 1/6] zsmalloc: remove insert_zspage() ->inuse optimization Message-ID: References: <20230223030451.543162-1-senozhatsky@chromium.org> <20230223030451.543162-2-senozhatsky@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230223030451.543162-2-senozhatsky@chromium.org> X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: qw93q8z5dg34adsigqyyqxdodjg16wja X-Rspamd-Queue-Id: 7F8C220006 X-HE-Tag: 1677193776-851436 X-HE-Meta: U2FsdGVkX18/vjhDVWxP4oI6v/WGJiB33mqGTojs3gtyjy9QAju/WFu156oim2oeOxJtOc4kmPzRzjHQysjW41FcJluvawx4VE792s2zRzA+cnW+3JmF1rmztjuoP9345w99zv9knSgro2ELaBk72cTfSkgX+r9dPfu/T4j9b1wjMddIqIfxTzFhjVbcbIdLWo2QHliClFwHo3OOc+CBweyRRN2DADQIVNoInzQwauLjlKEnFjvdIbtG9pMpt5HbesdeemkwUDXDD6F6lsV9+/wc9OLTA3Fv6Dt5D0VkZIVpViAapRLdGlllPBkWVaWWR9U81VY5iMJ3nRP3Tj0hYLm3CIJhBFqGxSurYJuTtbnr7SozkV0RrjwIMHj0mi0dHSyLvXTYmlLxM6e+4SlrUO+YApl+j7ZyDld5KSWUVUpKx8Y1kL1VRThC3Y/oc69jItTf3FAOMBiJx/jxbBZAfE+tehwZl75OmY/G5+c3+9IMwXp2UbpPHPM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1ZJk/fZZZTcTIWNJYEMW2lFfz2xRVgVJcb7tee7SuzT+kjdYkJZBLumQOfCpqS7Hzuhg7igrW9EGiTERGyVVLKEl1nGmfPo2dpryOWj9fPrRc7SAasusedR+zRB+nIglmPWc X-Bogosity: Ham, tests=bogofilter, spamicity=0.000008, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Feb 23, 2023 at 12:04:46PM +0900, Sergey Senozhatsky wrote: > This optimization has no effect. It only ensures that > when a page was added to its corresponding fullness > list, its "inuse" counter was higher or lower than the > "inuse" counter of the page at the head of the list. > The intention was to keep busy pages at the head, so > they could be filled up and moved to the ZS_FULL > fullness group more quickly. However, this doesn't work > as the "inuse" counter of a page can be modified by zspage Let's use term zspage instead of page to prevent confusing. > obj_free() but the page may still belong to the same > fullness list. So, fix_fullness_group() won't change Yes. I didn't expect it should be perfect from the beginning but would help just little optimization. > the page's position in relation to the head's "inuse" > counter, leading to a largely random order of pages > within the fullness list. Good point. > > For instance, consider a printout of the "inuse" > counters of the first 10 pages in a class that holds > 93 objects per zspage: > > ZS_ALMOST_EMPTY: 36 67 68 64 35 54 63 52 > > As we can see the page with the lowest "inuse" counter > is actually the head of the fullness list. Let's write what the patch is doing cleary "So, let's remove the pointless optimization" or something better word. > > Signed-off-by: Sergey Senozhatsky > --- > mm/zsmalloc.c | 29 ++++++++--------------------- > 1 file changed, 8 insertions(+), 21 deletions(-) > > diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c > index 3aed46ab7e6c..b57a89ed6f30 100644 > --- a/mm/zsmalloc.c > +++ b/mm/zsmalloc.c > @@ -753,37 +753,24 @@ static enum fullness_group get_fullness_group(struct size_class *class, > } > > /* > - * Each size class maintains various freelists and zspages are assigned > - * to one of these freelists based on the number of live objects they > - * have. This functions inserts the given zspage into the freelist > - * identified by . > + * This function adds the given zspage to the fullness list identified > + * by . > */ > static void insert_zspage(struct size_class *class, > - struct zspage *zspage, > - enum fullness_group fullness) > + struct zspage *zspage, > + enum fullness_group fullness) Unnecessary changes > { > - struct zspage *head; > - > class_stat_inc(class, fullness, 1); > - head = list_first_entry_or_null(&class->fullness_list[fullness], > - struct zspage, list); > - /* > - * We want to see more ZS_FULL pages and less almost empty/full. > - * Put pages with higher ->inuse first. > - */ > - if (head && get_zspage_inuse(zspage) < get_zspage_inuse(head)) > - list_add(&zspage->list, &head->list); > - else > - list_add(&zspage->list, &class->fullness_list[fullness]); > + list_add(&zspage->list, &class->fullness_list[fullness]); > } > > /* > - * This function removes the given zspage from the freelist identified > + * This function removes the given zspage from the fullness list identified > * by . > */ > static void remove_zspage(struct size_class *class, > - struct zspage *zspage, > - enum fullness_group fullness) > + struct zspage *zspage, > + enum fullness_group fullness) Ditto. Other than that, looks good to me.