Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2951491rwb; Fri, 9 Dec 2022 08:12:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf60r1y0fMe0/Ih3g+ovmBLHpNXCpVP8Idt3WVH3txN7EYwwXZjbqy4FhHxEQyf+E6c5nYzQ X-Received: by 2002:a05:6a21:2d07:b0:9e:9685:f15e with SMTP id tw7-20020a056a212d0700b0009e9685f15emr8921778pzb.0.1670602343077; Fri, 09 Dec 2022 08:12:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670602343; cv=none; d=google.com; s=arc-20160816; b=Li8xeON1aOw89qDhQPSvD+FfZKv+fkMCqmc1P73nhR0Ko6hprvPiPJG4Mo6kWy0Z7C TfyUckcnqZSM4IVDjU5d5rHzBTfeUrT+jjUQJJ8cHx3BPbcgv5SLE6FQAXxjvOHyCPYr Qqn/WRLBbFf13M9w5VhNmu6vpRqH66FOJwjE9oGC+PjSPlQR38azphwBuqeumJizL9xr GgERR+HfgAYYu1whJ7Ux7DbE1VJ73MBrLRLbo75DkvdqjpL90BsLei+l2cma7k+qvqH1 XaDLmJh1Ek/yhkKyRiTwb6Y0zem5V3w/PtcbSjeFbNZYfCsrBuyfL8j7KZQRb+iLbbH9 3E2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=XJPm4fwaRggOYMPWB+4OQhr2AoXrB0vtei9ZF45OHV8=; b=yra7/Ici1OykZXahoM08yIVdTj8m53oAaYaW1Zn5yUNrDX2mZhE/TqpaUjiPDvArGH bnPPY61muWseQR5DlbaESp8WaRL8Uc+Ru/JNRMUIqiuKzSaUM8+1LDLAi/LLM2Igj2KF lPV9XBjokakTUJES0zvaKUJ2LV9RWEQZOWniAJCKSCL5T67DznyO9zfgoVD4czY1HL5Z X4U3vEj/AqPQ6Vxq8WCxUx0EgWbu2rth6GrGXoywAsXwwB1gGeUVh/Vob4BdGHHymZ0u i8msAO0RnDU4HjfzIvSd9bpRSckrq09GhfkfHNOhYtk6bSwA5I0ZRdu3ULEbUEkf8zc3 Libw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AJeyRRMD; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u24-20020a632358000000b00477bbd92cf5si1843329pgm.118.2022.12.09.08.12.12; Fri, 09 Dec 2022 08:12:23 -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=@redhat.com header.s=mimecast20190719 header.b=AJeyRRMD; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230121AbiLIP7e (ORCPT + 75 others); Fri, 9 Dec 2022 10:59:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229949AbiLIP7c (ORCPT ); Fri, 9 Dec 2022 10:59:32 -0500 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 4E65F3B9E9 for ; Fri, 9 Dec 2022 07:58:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670601519; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XJPm4fwaRggOYMPWB+4OQhr2AoXrB0vtei9ZF45OHV8=; b=AJeyRRMDE0+GQwI7FL8lfAs9H614ONaCNxaRbiXhfjclswe2dscJ6GpgIDYNck6RkHCD+0 Bu3J7kV54WuhXphpptBbu/oqqF1hzy8oCWOzYTJK6aCftspsuxz0UkYr+2hGwKwGLnKbWk s1PTHe7ZtdSJbxJalZfq5624wzSgjds= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-486-B696t4EsMfiGoAAspXHKFA-1; Fri, 09 Dec 2022 10:58:36 -0500 X-MC-Unique: B696t4EsMfiGoAAspXHKFA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A33E429AA2EF; Fri, 9 Dec 2022 15:58:35 +0000 (UTC) Received: from [10.22.9.164] (unknown [10.22.9.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E1AE1401C30; Fri, 9 Dec 2022 15:58:34 +0000 (UTC) Message-ID: <8641d4a4-4d60-0f31-120c-56628f477ba2@redhat.com> Date: Fri, 9 Dec 2022 10:58:32 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: [PATCH-block 3/3] blk-cgroup: Flush stats at blkgs destruction path Content-Language: en-US To: Jens Axboe , Tejun Heo , Josef Bacik , Zefan Li , Johannes Weiner , Andrew Morton Cc: cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, =?UTF-8?Q?Michal_Koutn=c3=bd?= , "Dennis Zhou (Facebook)" References: <20221208220141.2625775-1-longman@redhat.com> <20221208220141.2625775-4-longman@redhat.com> From: Waiman Long In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 On 12/8/22 18:00, Jens Axboe wrote: > On 12/8/22 3:01?PM, Waiman Long wrote: >> diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c >> index 793ecff29038..910e633869b0 100644 >> --- a/kernel/cgroup/rstat.c >> +++ b/kernel/cgroup/rstat.c >> @@ -281,6 +281,26 @@ void cgroup_rstat_flush_release(void) >> spin_unlock_irq(&cgroup_rstat_lock); >> } >> >> +/** >> + * cgroup_rstat_css_cpu_flush - flush stats for the given css and cpu >> + * @css: target css to be flush >> + * @cpu: the cpu that holds the stats to be flush >> + * >> + * A lightweight rstat flush operation for a given css and cpu. >> + * Only the cpu_lock is being held for mutual exclusion, the cgroup_rstat_lock >> + * isn't used. >> + */ >> +void cgroup_rstat_css_cpu_flush(struct cgroup_subsys_state *css, int cpu) >> +{ >> + raw_spinlock_t *cpu_lock = per_cpu_ptr(&cgroup_rstat_cpu_lock, cpu); >> + >> + raw_spin_lock_irq(cpu_lock); >> + rcu_read_lock(); >> + css->ss->css_rstat_flush(css, cpu); >> + rcu_read_unlock(); >> + raw_spin_unlock_irq(cpu_lock); >> +} >> + >> int cgroup_rstat_init(struct cgroup *cgrp) >> { >> int cpu; > As I mentioned last time, raw_spin_lock_irq() will be equivalent to an > RCU protected section anyway, so you don't need to do both. Just add a > comment on why rcu_read_lock()/rcu_read_unlock() isn't needed inside the > raw irq safe lock. Yes, you are right.  We don't need rcu_read_lock() here. I put it there to follow the locking pattern in cgroup_rstat_flush_locked(). I will remove it in the next version. Cheers, Longman