From patchwork Wed Feb 8 16:16:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 5137 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3556996wrn; Wed, 8 Feb 2023 08:36:37 -0800 (PST) X-Google-Smtp-Source: AK7set/RZygmrn22QBZceOUMM9lrpkQWGE92pE3XLcSa1iKY/Njz2bFhmFDBaiMRhMEmkZcBQ/NI X-Received: by 2002:a62:828d:0:b0:593:fe34:96de with SMTP id w135-20020a62828d000000b00593fe3496demr6709761pfd.0.1675874197031; Wed, 08 Feb 2023 08:36:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675874197; cv=none; d=google.com; s=arc-20160816; b=y8OPfJDBS49ICZ/S4/aAi1Uligyxmxld6p/BdlISrvJBo+FS+Wh/v0RGXonKSli/Oj WOgt1KwqhcDZgM+nVzbyyEOUQx8IpQrWS55WMEEAmPzp1tjmHAj0JTEPVSmNgrm3YctK cYXrWbN0rPj/sEzJps9/RNG/fgNsoTGXW1eOGp3U/lwJlGTmr5CnhpHXND9lsB99rcJQ Jl3HIlxaGabKd2Q46Lfiu79LZPwA51hSqwFzC6WYF65vZ2kZl1hVbO2+7EmnjIaOy/Q4 R/oYwb2W2PyAyxvnQN5RVTuGzMXa/B8qvpRKzjXTweTroll6IatvqOlgvOZq9sYMuRDz iuCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Tzqq5s709T6l/w+9pi74lxvpe8BbE2WIdW1BUQhpDbQ=; b=ciOcaKWbMBxrI8K0pFXFWUhpiINNbmZicIHzRQ0vd810KCLHUJxTM00fhiBnifMlOL ngCLiw11Iaai6QunMmFs2ajrEghIsnullEnrU+YMPKDO3VtccRt00fUidlXNAYCsQ+QS zEOg16fmvvqRPEiycXC1V90t5Mcq+jybMAi2vBWLOxtt3H+nbE2HE6yqvVWSzyoAJVDh lOsblOTTowRgh7FW09cSdNuGNE2lNj8db9PgZIQBQGR+8uhq/Iw15QbvbwXOGERsq8qQ h/SIa0ZiKp7g7zx4PqrIfKpKdksLv6GvV28KI6Jjt1lti912/rC02KULVVNhc3ejYuj3 ms3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=noT7JHKs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f12-20020a056a0022cc00b00594356992a1si3672241pfj.108.2023.02.08.08.36.24; Wed, 08 Feb 2023 08:36:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=noT7JHKs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230167AbjBHQSE (ORCPT + 99 others); Wed, 8 Feb 2023 11:18:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229512AbjBHQSC (ORCPT ); Wed, 8 Feb 2023 11:18:02 -0500 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31CAD10FD; Wed, 8 Feb 2023 08:17:50 -0800 (PST) Received: by mail-pf1-x436.google.com with SMTP id ay1so13436913pfb.7; Wed, 08 Feb 2023 08:17:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=Tzqq5s709T6l/w+9pi74lxvpe8BbE2WIdW1BUQhpDbQ=; b=noT7JHKssXq5HEmHAxZXC82FcLwo5xxQtOr1L4ExZ113d77QoohSj2CtErhGNEPtNd DmtzNw8zA34e6E8miyKkEx44kh6DySdQBGI/sfJoVSWoh3ZT6J2LfEVc2A9CFTscmziJ x3UJauD26xL2f6CCeEOAjHeSy4ja/vBftnMF+2osuOJjr/S7tqbZbEPlMEOdx4zl13IM BT05bjXcVILKBEJtE8WA7bJ7DzeL7Xp992kAjhLFuJ2Uden55LIMRM3meXYvwx8LmF8v be44fgwHbzaZo8IeeFceI70f3HPCYFsMzdE8Nj2GelKZHOXurCHDdi8vSb/LDY1zAOPq Zazw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Tzqq5s709T6l/w+9pi74lxvpe8BbE2WIdW1BUQhpDbQ=; b=cdfCrmaWkMM7uEhMXlWDkFHv6qYn/9bOvL6zvv4B9UBJKTyaciQFgaQ+ibhRqnrARl NBsW10HCQkxr/ZhTXXXSAFReZ5bleUm//o14cEYrPba03q7txspApu3xNYQ45R/fX6Ps qyCnLnJOSFBlSRn0V9ckaUyqTpdUDj+tAG1Qpa3tAd/UavQWDufy37xYNwqDmHvqvS+k g2xqo6afAN7HAzU0OOkZb7fm0G5BwHzhI4v7XUvtT1BBeOaBRWtMBKQ1y2bZIslrswap yoZkUIx7ZyZ8At0EQAAUVK+u3xuOU2wNoxO+vaSTZ3ZBpT+HPaGLz4CFT5SGxCBuPrxK aMpw== X-Gm-Message-State: AO0yUKXOk4b2LUdUCnSn24EN2W1384/hE08uPPZ8YDWBQN5Pg7FFa77b 5gAHfmV61bMj2+Tw/13PlRc= X-Received: by 2002:a62:1792:0:b0:592:705a:5a5e with SMTP id 140-20020a621792000000b00592705a5a5emr6712838pfx.9.1675873069577; Wed, 08 Feb 2023 08:17:49 -0800 (PST) Received: from KASONG-MB0.tencent.com ([115.171.40.195]) by smtp.gmail.com with ESMTPSA id s21-20020a056a00195500b0059252afc069sm11445485pfk.64.2023.02.08.08.17.45 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 08 Feb 2023 08:17:48 -0800 (PST) From: Kairui Song To: Johannes Weiner , Suren Baghdasaryan Cc: Chengming Zhou , =?utf-8?q?Michal_Koutn?= =?utf-8?q?=C3=BD?= , Tejun Heo , Ingo Molnar , Peter Zijlstra , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH 0/2] sched/psi: Optimize PSI iteration Date: Thu, 9 Feb 2023 00:16:52 +0800 Message-Id: <20230208161654.99556-1-ryncsn@gmail.com> X-Mailer: git-send-email 2.35.2 Reply-To: Kairui Song MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757281462233918313?= X-GMAIL-MSGID: =?utf-8?q?1757281462233918313?= Hi all, Patch 1/2 simplify cgroup_psi, I didn't see a measurable performance change with this. Patch 2/2 removed the cache, I just noticed it have the same hierarchy as the cgroup it's in, so I wondered if it worth adding a cache just for simplifying the branch, and if we can balance the branch simplification and minimize the memory footprint in another way, it seems this is doable. After the two patches, I see a measurable performance gain using mmtests/perfpipe: (AVG of 100 test, ops/sec, the higher the better) KVM guest on a i7-9700: psi=0 root cgroup 5 levels of cgroup Before: 59221 55352 47821 After: 60100 56036 50884 KVM guest on a Ryzen 9 5900HX: psi=0 root cgroup 5 levels of cgroup Before: 144566 138919 128888 After: 145812 139580 133514 Kairui Song (2): sched/psi: simplify cgroup psi retrieving sched/psi: iterate through cgroups directly include/linux/psi.h | 2 +- include/linux/psi_types.h | 1 - kernel/cgroup/cgroup.c | 7 +++++- kernel/sched/psi.c | 45 ++++++++++++++++++++++++++++----------- 4 files changed, 39 insertions(+), 16 deletions(-)