Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp885164rdf; Fri, 3 Nov 2023 20:14:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF3rJ+8VXB1pQ15NAxrdfXhHI8cbYwN+owYkq4Orko8O9gdz7c2rjTCVVqGv8+qar4k41c7 X-Received: by 2002:a17:902:f1d2:b0:1c2:1068:1f4f with SMTP id e18-20020a170902f1d200b001c210681f4fmr21236973plc.17.1699067668327; Fri, 03 Nov 2023 20:14:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699067668; cv=none; d=google.com; s=arc-20160816; b=aB6/XqUiucvjOZ4yVcmuWyC0CALjl2B8ii62iyc+zuBDJW4MBeZoqi+A4OlLDF240m urCmZuMTrG9a4mLCQRaygpUe7OWB6PsWuxupGwV/SZw7l3VJbVldsOKG/RMYvf9eVhvK qioK/SpmLmd2n97w6HGw4vk9EGq3FEJKIU3NtGTtR30VbxjZW5lQukWQ3DJTvYoyh5jj o6teFA6nh62pnfJp2VbJQfP5EBydYphcFnTp0pWDjP3wBpqjCZTBEasDCn2rUG7W/ooJ 5z0M34tCW3J/euuh/v9d6JiPCZD63qdXRQKRU0owMLyS0e69vJ79ie5GjLyVsp1FoMky 02kw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=N5kFWH7brXucsVBRzdMRgJtcTW19s76elB4wot7GI30=; fh=vy39GFVfO6UaqrntP4AkYjitNZbWGjYvUyBXYh7mu0A=; b=oLstRpmgwPSRE2oM8f9isT3sl9MGlloXY/groYu9QiVXd51D54a/QWVi5Q3tLgXy0F 0fRiuZI6H07n2CvY89XKAVrwietjfivMQampqRKKPbD7749gykxaHOGgZzA3WO0eW4Xy MrRZlW7QDPr3sSX+7zGpQEOZOX+BTTVjaUGxGtBS8aUDp6fDyalofI0TljRrzNVUJ99B fKOYWZRr9w9N4FEPnmEoDPylzuVMHg3DlC6BTsnzJfEc2B1pfg/CXfdU2fJCc5JRorMm Vagwl3M0gvNAsMsX4SkGWyTEsDWV0CW0jWZuYI+IRDMp1j/DY5+p1njqejY4YqyOg90H PAaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cqVGQ2do; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id l19-20020a170902e2d300b001cc4aca5f5dsi2647147plc.636.2023.11.03.20.14.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 20:14:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cqVGQ2do; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id AB48281E5E70; Fri, 3 Nov 2023 20:14:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235061AbjKDDOS (ORCPT + 99 others); Fri, 3 Nov 2023 23:14:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235089AbjKDDOP (ORCPT ); Fri, 3 Nov 2023 23:14:15 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E232D60 for ; Fri, 3 Nov 2023 20:13:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699067601; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=N5kFWH7brXucsVBRzdMRgJtcTW19s76elB4wot7GI30=; b=cqVGQ2doywZMX6vBYGWI28qjqfCaKCa+N4Jqgd7Y7w55DMixHXe75yZRnYLgW10TVQQkPh 5hVV4AK4OcU/tz1t5TEdrOYNTud8PKJohrSdf+FSc7E7J1dM3jZ/tQs44Kwufwci3ne6mE 8Q4RVaWNaWcLcKRQZ4gQHottsWyc8cI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-114-FHsGKWLoMzyJ9-2FyZjS9A-1; Fri, 03 Nov 2023 23:13:17 -0400 X-MC-Unique: FHsGKWLoMzyJ9-2FyZjS9A-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 71975811003; Sat, 4 Nov 2023 03:13:17 +0000 (UTC) Received: from llong.com (unknown [10.22.33.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8BE49C1290F; Sat, 4 Nov 2023 03:13:16 +0000 (UTC) From: Waiman Long To: Tejun Heo , Zefan Li , Johannes Weiner Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Joe Mario , Sebastian Jug , Yosry Ahmed , Waiman Long Subject: [PATCH v3 0/3] cgroup/rstat: Reduce cpu_lock hold time in cgroup_rstat_flush_locked() Date: Fri, 3 Nov 2023 23:13:00 -0400 Message-Id: <20231104031303.592879-1-longman@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 03 Nov 2023 20:14:26 -0700 (PDT) v3: - Minor comment twisting as suggested by Yosry. - Add patches 2 and 3 to further reduce lock hold time The purpose of this patch series is to reduce of the cpu_lock hold time in cgroup_rstat_flush_locked() so as to reduce the latency impact when cgroup_rstat_updated() is called as they may contend with each other on the cpu_lock. A parallel kernel build on a 2-socket x86-64 server is used as the benchmarking tool for measuring the lock hold time. Below were the lock hold time frequency distribution before and after applying different number of patches: Hold time Before patch Patch 1 Patches 1-2 Patches 1-3 --------- ------------ ------- ----------- ----------- 0-01 us 804,139 13,738,708 14,594,545 15,484,707 01-05 us 9,772,767 1,177,194 439,926 207,382 05-10 us 4,595,028 4,984 5,960 3,174 10-15 us 303,481 3,562 3,543 3,006 15-20 us 78,971 1,314 1,397 1,066 20-25 us 24,583 18 25 15 25-30 us 6,908 12 12 10 30-40 us 8,015 40-50 us 2,192 50-60 us 316 60-70 us 43 70-80 us 7 80-90 us 2 >90 us 3 Waiman Long (3): cgroup/rstat: Reduce cpu_lock hold time in cgroup_rstat_flush_locked() cgroup/rstat: Optimize cgroup_rstat_updated_list() cgroup: Avoid false cacheline sharing of read mostly rstat_cpu include/linux/cgroup-defs.h | 14 ++++ kernel/cgroup/rstat.c | 129 +++++++++++++++++++++--------------- 2 files changed, 89 insertions(+), 54 deletions(-) -- 2.39.3