Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2708542pxb; Fri, 17 Sep 2021 16:39:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlXtqt/nxsBzzVtY1Zxqugd5cRuSTFnHwxyal+DaixHP4Y8EOwj+FvaRc07tMbtK/NnHEq X-Received: by 2002:a05:6638:3881:: with SMTP id b1mr964871jav.119.1631921954442; Fri, 17 Sep 2021 16:39:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631921954; cv=none; d=google.com; s=arc-20160816; b=bAIAdlTwJGPcabQmAavqppdH0sElU4kyZYXGbD9HRoos4x+ssAO734qpsNyU+cslIW LwX+/4kFDylHhIzb3gyfGoJY1zRtvZTbnDk64s7rvQt9YjRizIKDcYzS9WfcQUaVUQPu 5oxQDDLVZ90zjnnQsa0XHV4vKe2xOzI6iGTk1hcXxuw2p1PqiTMKyRexw3xceui08+pE 1h+5Gf+3KG4SYjGxNzcV4id24O/97Cgah98zR06V2PpaDQ/fJzNqAhHKfq31jmEtx4ym mLzQ2zsjDy3KJw90AYA3Ul9eX+MZ7R/IxH9SUTiFUOcqSYRi7iUdhvltgqBwTI2IA/CJ jP3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=zxCLMiwgNRNijtEYpMVJcX6xlScUvdnPIRXCubpCOuE=; b=jpLJIDpFG45A/hWmfh6BU/A1Sqn3V2nCT38OrLr9l/t8Zh/c0LASMNjJ36r3OHKc4s lQdv+0OaCe1IU3nAV1f8rwKRwdsrDdYYQmCZJLmTBwFuIwCpMaxMb/Y9VHe4pP7eQDBd /Z/g5riheUspgrKJwELPCn4YI55GHKCq0IaZ4iL0yw8QZle+47leOvEzjSLsSEMGhma+ eABu4irxphK4hSSeizsBc987+6urOlADUvecXjsJgff/AJ+xZ4wIx7N6LvPVbdCQuLVN 6mfzyD3uqhtClJFqHaEMtw5aW1sB5+0lksfHThvI4qPM6HidVmfJz+UA+o319VVSkRvA Fsmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Y0S+zKjp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n10si6585151jaf.0.2021.09.17.16.39.02; Fri, 17 Sep 2021 16:39:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Y0S+zKjp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243206AbhIQPkK (ORCPT + 99 others); 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-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.