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 X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0FE09C433F5 for ; Fri, 17 Sep 2021 15:38:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EDE4061212 for ; Fri, 17 Sep 2021 15:38:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243221AbhIQPkK (ORCPT ); Fri, 17 Sep 2021 11:40:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241898AbhIQPkH (ORCPT ); Fri, 17 Sep 2021 11:40:07 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE3A5C061574; Fri, 17 Sep 2021 08:38:44 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id c21so31267478edj.0; Fri, 17 Sep 2021 08:38:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=zxCLMiwgNRNijtEYpMVJcX6xlScUvdnPIRXCubpCOuE=; b=Y0S+zKjpf3Rgo+qWJaUXBauspRABthhE5vW8jiUnn2i4SxsmTCovLFND1qUoBfJKLN XUSSCxC1YRkj7NyGevUuDKtg6/K8clJWXyAFSYBa/jAh9r1oZMe6WhnlbcCWqRlKtEC8 qSL0j35NOoBrV4IRdPAReh5OTfuGWnbPwUiLjrfBqs3ZfGj8RWsLxx/yJSuAn1lJoyoN Sfk9XbCDZFbkJEcl5K4okuAJ8Fnh+AM++3HMl8yHSejRPCWHCUhXq1a5HUTabRxiYUhY 4CPVf0vq4zD2uHEsrP6JAEq51HlEDVIpc7W7eQNJ5rUFqsYi4IJDsUmH4k/AisP+FDO6 U7IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=zxCLMiwgNRNijtEYpMVJcX6xlScUvdnPIRXCubpCOuE=; b=kzfXvz1j3uw1LN/WhixOj001MUvI/T0AzjT6795phMnDeh8er0Nf6ZtGaLa1uq9/we fpnLnCFjMFfR0mfacgE6cqVj5hHfaBsoZUaiftBlx88O0uY+IP3wLzqH/6zgEg2Zkw7+ FG15BHo/0VpFUUfdoromglgZ0so2piirh9CFKwzwy0IEtk3olUnHa+/f8q2Kq88s8xbG lRzzRwLlwMe+1FaE+0fCltixI2rrXe0RK6aRZKBGy/r9UQcgLxoutuTlPA97vSF0HvGh /t36+jtnZ1bM2wLCL1VBTApkR1uenN+jYrnax6KkPubjm6F9PZiDZNeeiIoprmta07X1 0shg== X-Gm-Message-State: AOAM530KhZMF4aZ8amAAtSzXTtBLO5d27DwCbwxE4Heu+L/48Cb/uJ3J GyxdnHigAzyYFFY5qzetE64Pk7WfKkLCqMqTKGs= X-Google-Smtp-Source: ABdhPJzuTeICPGu0FEYeFqBrz2DYqD4swqzp/3wVCprj2Nwqq4Irleac2DOscZZ36VisVtuBaLgFLoCv8/qAfZ2Tz1o= X-Received: by 2002:a17:906:3c56:: with SMTP id i22mr12938477ejg.287.1631893122771; Fri, 17 Sep 2021 08:38:42 -0700 (PDT) MIME-Version: 1.0 References: <1631635551-8583-1-git-send-email-wang.yong12@zte.com.cn> In-Reply-To: From: yong w Date: Fri, 17 Sep 2021 23:38:31 +0800 Message-ID: Subject: Re: [PATCH v2] vmpressure: wake up work only when there is registration event To: Michal Hocko Cc: Tejun Heo , "Peter Zijlstra (Intel)" , wang.yong12@zte.com.cn, Cgroups , LKML , Linux MM , yang.yang29@zte.com.cn Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Michal Hocko =E4=BA=8E2021=E5=B9=B49=E6=9C=8815=E6=97=A5= =E5=91=A8=E4=B8=89 =E4=B8=8B=E5=8D=888:42=E5=86=99=E9=81=93=EF=BC=9A > > On Tue 14-09-21 09:05:51, yongw.pur@gmail.com wrote: > > From: wangyong > > > > Use the global variable num_events to record the number of vmpressure > > events registered by the system, and wake up work only when there is > > registration event. > > Usually, the vmpressure event is not registered in the system, this pat= ch > > can avoid waking up work and doing nothing. > > I have asked in the previous version and this changelog doesn't that > explain again. Why don't you simply bail out early in vmpressure() > entry? Thanks for your reply. Because the else branch will modify the socket_pressure, and will not wake = up the work. It is necessary to judge the tree parameters at the same time, like this if (tree && !static_branch_unlikely(&num_events)) return; It's not good to judge the tree twice parameters in the function. > > > Test with 5.14.0-rc5-next-20210813 on x86_64 4G ram. > > Consume cgroup memory until it is about to be reclaimed, then execute > > "perf stat -I 2000 malloc.out" command to trigger memory reclamation > > and get performance results. > > The context-switches is reduced by about 20 times. > > Is this test somewhere available so that it can be reproduced by > others. Also while the number of context switches can be an interesting > it is not really clear from this evaluation whether that actually > matters or not. E.g. what does an increase of task-clock and twice as > many instructions recorded tell us? > The test program is a simple malloc process, which allocate memory and fill some data. I think it may be that more instructions can be executed per unit time. > > unpatched: > > Average of 10 test results > > 582.4674048 task-clock(msec) > > 19910.8 context-switches > > 0 cpu-migrations > > 1292.9 page-faults > > 414784733.1 cycles > > > stalled-cycles-frontend > > stalled-cycles-backend > > Why is this a part of the data? > > > 580070698.4 instructions > > 125572244.7 branches > > 2073541.2 branch-misses > > > > patched > > Average of 10 test results > > 973.6174796 task-clock(msec) > > 988.6 context-switches > > 0 cpu-migrations > > 1785.2 page-faults > > 772883602.4 cycles > > stalled-cycles-frontend > > stalled-cycles-backend > > 1360280911 instructions > > 290519434.9 branches > > 3378378.2 branch-misses > > > > Tested-by: Zeal Robot > > Signed-off-by: wangyong > > --- > > > [...] > > @@ -272,6 +277,9 @@ void vmpressure(gfp_t gfp, struct mem_cgroup *memcg= , bool tree, > > return; > > > > if (tree) { > > + if (!static_branch_unlikely(&num_events)) > > + return; > > We usually hide the change behind a static inline helper (e.g. > vmpressure_disabled()). I would also put it to the beginning of > vmpressure or put an explanation why it makes sense only in this branch. > -- Because only this branch needs to wake up work. Yes, static inline helper is more easier to read and understand. 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 X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73469C433F5 for ; Fri, 17 Sep 2021 17:03:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0426E60F70 for ; Fri, 17 Sep 2021 17:03:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0426E60F70 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 9EEB2900002; Fri, 17 Sep 2021 13:03:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 975E16B0074; Fri, 17 Sep 2021 13:03:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 81747900002; Fri, 17 Sep 2021 13:03:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0126.hostedemail.com [216.40.44.126]) by kanga.kvack.org (Postfix) with ESMTP id 732706B0073 for ; Fri, 17 Sep 2021 13:03:43 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 20663824C452 for ; Fri, 17 Sep 2021 17:03:43 +0000 (UTC) X-FDA: 78597687126.16.614655D Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) by imf06.hostedemail.com (Postfix) with ESMTP id C315180E2811 for ; Fri, 17 Sep 2021 15:38:45 +0000 (UTC) Received: by mail-ed1-f49.google.com with SMTP id v5so31105606edc.2 for ; Fri, 17 Sep 2021 08:38:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=zxCLMiwgNRNijtEYpMVJcX6xlScUvdnPIRXCubpCOuE=; b=Y0S+zKjpf3Rgo+qWJaUXBauspRABthhE5vW8jiUnn2i4SxsmTCovLFND1qUoBfJKLN XUSSCxC1YRkj7NyGevUuDKtg6/K8clJWXyAFSYBa/jAh9r1oZMe6WhnlbcCWqRlKtEC8 qSL0j35NOoBrV4IRdPAReh5OTfuGWnbPwUiLjrfBqs3ZfGj8RWsLxx/yJSuAn1lJoyoN Sfk9XbCDZFbkJEcl5K4okuAJ8Fnh+AM++3HMl8yHSejRPCWHCUhXq1a5HUTabRxiYUhY 4CPVf0vq4zD2uHEsrP6JAEq51HlEDVIpc7W7eQNJ5rUFqsYi4IJDsUmH4k/AisP+FDO6 U7IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=zxCLMiwgNRNijtEYpMVJcX6xlScUvdnPIRXCubpCOuE=; b=bkgQ1atylWp82AKnjpt4qmaV5plSzoVwfxO1b3YMtkzy/x3nYEgOLTOOCC6stD8pnA wLjxA79WES5CRZcxHsRV8Bhtu7KVFrhuyrDamTrvq6sdxyMmDXglBsjF5ev901xpEdAH TZKCURmXEmS3deRKh81O2PSqfNr/AwmqgtC43m4nGAzJFRJ3lNjE5p6F050TAdsWrkKy IUDqfce3lEL97TrSdoi1wFIeTycQcvWm8o4ZUtS5JO2NABWdxGqBfpuRWxikNRiydGGP w9xXLw7aXFTxxdhaxrW7UatCI+tHvfORVLW5I2Iebot6iGo1/vEElIzcCETAgnWUOqFp qoig== X-Gm-Message-State: AOAM5339xbVzWizqUKj1lvhg0QY7AT5Q5MFWz0hVwtLmNPyg3vE4ncjT jRMgjNcPKwRjWEwKwwBniRgCKMu8q3y3bmI/TWs= X-Google-Smtp-Source: ABdhPJzuTeICPGu0FEYeFqBrz2DYqD4swqzp/3wVCprj2Nwqq4Irleac2DOscZZ36VisVtuBaLgFLoCv8/qAfZ2Tz1o= X-Received: by 2002:a17:906:3c56:: with SMTP id i22mr12938477ejg.287.1631893122771; Fri, 17 Sep 2021 08:38:42 -0700 (PDT) MIME-Version: 1.0 References: <1631635551-8583-1-git-send-email-wang.yong12@zte.com.cn> In-Reply-To: From: yong w Date: Fri, 17 Sep 2021 23:38:31 +0800 Message-ID: Subject: Re: [PATCH v2] vmpressure: wake up work only when there is registration event To: Michal Hocko Cc: Tejun Heo , "Peter Zijlstra (Intel)" , wang.yong12@zte.com.cn, Cgroups , LKML , Linux MM , yang.yang29@zte.com.cn Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: C315180E2811 X-Stat-Signature: p8xtycf8wkaqhkohd3yej3tyegj43mj5 Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Y0S+zKjp; spf=pass (imf06.hostedemail.com: domain of yongw.pur@gmail.com designates 209.85.208.49 as permitted sender) smtp.mailfrom=yongw.pur@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1631893125-966450 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: Michal Hocko =E4=BA=8E2021=E5=B9=B49=E6=9C=8815=E6=97=A5= =E5=91=A8=E4=B8=89 =E4=B8=8B=E5=8D=888:42=E5=86=99=E9=81=93=EF=BC=9A > > On Tue 14-09-21 09:05:51, yongw.pur@gmail.com wrote: > > From: wangyong > > > > Use the global variable num_events to record the number of vmpressure > > events registered by the system, and wake up work only when there is > > registration event. > > Usually, the vmpressure event is not registered in the system, this pat= ch > > can avoid waking up work and doing nothing. > > I have asked in the previous version and this changelog doesn't that > explain again. Why don't you simply bail out early in vmpressure() > entry? Thanks for your reply. Because the else branch will modify the socket_pressure, and will not wake = up the work. It is necessary to judge the tree parameters at the same time, like this if (tree && !static_branch_unlikely(&num_events)) return; It's not good to judge the tree twice parameters in the function. > > > Test with 5.14.0-rc5-next-20210813 on x86_64 4G ram. > > Consume cgroup memory until it is about to be reclaimed, then execute > > "perf stat -I 2000 malloc.out" command to trigger memory reclamation > > and get performance results. > > The context-switches is reduced by about 20 times. > > Is this test somewhere available so that it can be reproduced by > others. Also while the number of context switches can be an interesting > it is not really clear from this evaluation whether that actually > matters or not. E.g. what does an increase of task-clock and twice as > many instructions recorded tell us? > The test program is a simple malloc process, which allocate memory and fill some data. I think it may be that more instructions can be executed per unit time. > > unpatched: > > Average of 10 test results > > 582.4674048 task-clock(msec) > > 19910.8 context-switches > > 0 cpu-migrations > > 1292.9 page-faults > > 414784733.1 cycles > > > stalled-cycles-frontend > > stalled-cycles-backend > > Why is this a part of the data? > > > 580070698.4 instructions > > 125572244.7 branches > > 2073541.2 branch-misses > > > > patched > > Average of 10 test results > > 973.6174796 task-clock(msec) > > 988.6 context-switches > > 0 cpu-migrations > > 1785.2 page-faults > > 772883602.4 cycles > > stalled-cycles-frontend > > stalled-cycles-backend > > 1360280911 instructions > > 290519434.9 branches > > 3378378.2 branch-misses > > > > Tested-by: Zeal Robot > > Signed-off-by: wangyong > > --- > > > [...] > > @@ -272,6 +277,9 @@ void vmpressure(gfp_t gfp, struct mem_cgroup *memcg= , bool tree, > > return; > > > > if (tree) { > > + if (!static_branch_unlikely(&num_events)) > > + return; > > We usually hide the change behind a static inline helper (e.g. > vmpressure_disabled()). I would also put it to the beginning of > vmpressure or put an explanation why it makes sense only in this branch. > -- Because only this branch needs to wake up work. Yes, static inline helper is more easier to read and understand. From mboxrd@z Thu Jan 1 00:00:00 1970 From: yong w Subject: Re: [PATCH v2] vmpressure: wake up work only when there is registration event Date: Fri, 17 Sep 2021 23:38:31 +0800 Message-ID: References: <1631635551-8583-1-git-send-email-wang.yong12@zte.com.cn> Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=zxCLMiwgNRNijtEYpMVJcX6xlScUvdnPIRXCubpCOuE=; b=Y0S+zKjpf3Rgo+qWJaUXBauspRABthhE5vW8jiUnn2i4SxsmTCovLFND1qUoBfJKLN XUSSCxC1YRkj7NyGevUuDKtg6/K8clJWXyAFSYBa/jAh9r1oZMe6WhnlbcCWqRlKtEC8 qSL0j35NOoBrV4IRdPAReh5OTfuGWnbPwUiLjrfBqs3ZfGj8RWsLxx/yJSuAn1lJoyoN Sfk9XbCDZFbkJEcl5K4okuAJ8Fnh+AM++3HMl8yHSejRPCWHCUhXq1a5HUTabRxiYUhY 4CPVf0vq4zD2uHEsrP6JAEq51HlEDVIpc7W7eQNJ5rUFqsYi4IJDsUmH4k/AisP+FDO6 U7IQ== In-Reply-To: List-ID: Content-Type: text/plain; charset="utf-8" To: Michal Hocko Cc: Tejun Heo , "Peter Zijlstra (Intel)" , wang.yong12-Th6q7B73Y6EnDS1+zs4M5A@public.gmane.org, Cgroups , LKML , Linux MM , yang.yang29-Th6q7B73Y6EnDS1+zs4M5A@public.gmane.org Michal Hocko =E4=BA=8E2021=E5=B9=B49=E6=9C=8815=E6=97=A5= =E5=91=A8=E4=B8=89 =E4=B8=8B=E5=8D=888:42=E5=86=99=E9=81=93=EF=BC=9A > > On Tue 14-09-21 09:05:51, yongw.pur-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > > From: wangyong > > > > Use the global variable num_events to record the number of vmpressure > > events registered by the system, and wake up work only when there is > > registration event. > > Usually, the vmpressure event is not registered in the system, this pat= ch > > can avoid waking up work and doing nothing. > > I have asked in the previous version and this changelog doesn't that > explain again. Why don't you simply bail out early in vmpressure() > entry? Thanks for your reply. Because the else branch will modify the socket_pressure, and will not wake = up the work. It is necessary to judge the tree parameters at the same time, like this if (tree && !static_branch_unlikely(&num_events)) return; It's not good to judge the tree twice parameters in the function. > > > Test with 5.14.0-rc5-next-20210813 on x86_64 4G ram. > > Consume cgroup memory until it is about to be reclaimed, then execute > > "perf stat -I 2000 malloc.out" command to trigger memory reclamation > > and get performance results. > > The context-switches is reduced by about 20 times. > > Is this test somewhere available so that it can be reproduced by > others. Also while the number of context switches can be an interesting > it is not really clear from this evaluation whether that actually > matters or not. E.g. what does an increase of task-clock and twice as > many instructions recorded tell us? > The test program is a simple malloc process, which allocate memory and fill some data. I think it may be that more instructions can be executed per unit time. > > unpatched: > > Average of 10 test results > > 582.4674048 task-clock(msec) > > 19910.8 context-switches > > 0 cpu-migrations > > 1292.9 page-faults > > 414784733.1 cycles > > > stalled-cycles-frontend > > stalled-cycles-backend > > Why is this a part of the data? > > > 580070698.4 instructions > > 125572244.7 branches > > 2073541.2 branch-misses > > > > patched > > Average of 10 test results > > 973.6174796 task-clock(msec) > > 988.6 context-switches > > 0 cpu-migrations > > 1785.2 page-faults > > 772883602.4 cycles > > stalled-cycles-frontend > > stalled-cycles-backend > > 1360280911 instructions > > 290519434.9 branches > > 3378378.2 branch-misses > > > > Tested-by: Zeal Robot > > Signed-off-by: wangyong > > --- > > > [...] > > @@ -272,6 +277,9 @@ void vmpressure(gfp_t gfp, struct mem_cgroup *memcg= , bool tree, > > return; > > > > if (tree) { > > + if (!static_branch_unlikely(&num_events)) > > + return; > > We usually hide the change behind a static inline helper (e.g. > vmpressure_disabled()). I would also put it to the beginning of > vmpressure or put an explanation why it makes sense only in this branch. > -- Because only this branch needs to wake up work. Yes, static inline helper is more easier to read and understand.