Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp498768imn; Wed, 27 Jul 2022 11:55:30 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s2NSNoYmd+CS/ifCqwSrFO1C2d9Xp9Ce/giOEJNm1XINJnXconjKsPcGeiedUFZrcgWRsi X-Received: by 2002:a17:907:a40d:b0:72b:7f56:650 with SMTP id sg13-20020a170907a40d00b0072b7f560650mr18443048ejc.132.1658948130748; Wed, 27 Jul 2022 11:55:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658948130; cv=none; d=google.com; s=arc-20160816; b=KXzJvt6F8fqG0vT5HmfdgPK/Fg1P/htJYJicNlI2ASJs3AtXI8UoUJXs9ChnTscbYJ yJUuni92eOr671AXGWILKx6puwm2YosUfEcpKLzONYhP0e4RY9nKoNDMi3taassxlLHc JjXcoraap85FgNlF1LIxBWqJapx0e0jwoAeBkPXht0cQihGyKWEWXTx/Sdv1C2xw34ir kKaUAGv68HVmxILgMRCwM8jiHLLG9HnzUx5ihwG/NUxqyiH45sjKq7p7C3ShQqG5A4gs TjMZ+DKBhnyGHypv2wR65LUXdAL2P8ugzaxTVN+RwGk/Fy5r5xxmCMK5QkP3rkoLVGX9 MN7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=R5b5gVej4MQa9hZ7l9p+CF9FxGIX65gr66TPXFnDVek=; b=vl7ZoyRjEk4OL/YH1pnhJQNaQyXDNBdcfJDz3LRMfzhiVrEG6oQFW1XVZ74wQyDnyO yhPdgAV6Blt5cvQwWCHj6z+YVwA34BZmKswPNmHoMcfXTGUrzcqEIKfj+cIEYMyLEaoF dsiTOB1r8fLoC1ZO0XgTvEx0Ki/jlG8Cxtt6jf5iAZ3UQYPvDyVAk1LUAo3cUeD/lQVY 8KrfehHDbldXVkafHKqHglO2Owkf7u4ugHEqeVfP26XEyYxWWSQ9Wn2dN6CC58yGEbht Bu1xHva043Xa+LF4q7gLbxVWjh/ErJwDy8dVTIgRV++NIBoi70keGtuwcUTHLLpLcYXC RP4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bSz4tKA6; 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 n26-20020aa7c45a000000b0043cd07bb8c3si759241edr.380.2022.07.27.11.55.05; Wed, 27 Jul 2022 11:55:30 -0700 (PDT) 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=bSz4tKA6; 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 S239910AbiG0SmP (ORCPT + 99 others); Wed, 27 Jul 2022 14:42:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234280AbiG0Sl7 (ORCPT ); Wed, 27 Jul 2022 14:41:59 -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 ESMTP id 432F961D5B for ; Wed, 27 Jul 2022 10:39:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658943554; 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: in-reply-to:in-reply-to:references:references; bh=R5b5gVej4MQa9hZ7l9p+CF9FxGIX65gr66TPXFnDVek=; b=bSz4tKA60k+kphl1rQUIu1Lh1Ef+HRW6vu5ylVOYwsu0I4HVOmhefy96Of3cQ0zXqIYXYv sDn8zikyijlJwC1403jHSBVKUwDF0BMnFwIMwzbV/IIt7+t4wYWVjCJf5WbeFwlS/SZJBX W8Dckuoxt/hlgP1fRBjJb2fxP2UHegA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-392-1FOChaSJNo2NPllRWIsRog-1; Wed, 27 Jul 2022 13:39:11 -0400 X-MC-Unique: 1FOChaSJNo2NPllRWIsRog-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2494785A58A; Wed, 27 Jul 2022 17:39:11 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.40.194.193]) by smtp.corp.redhat.com (Postfix) with SMTP id 1541C2026D64; Wed, 27 Jul 2022 17:39:08 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Wed, 27 Jul 2022 19:39:10 +0200 (CEST) Date: Wed, 27 Jul 2022 19:39:08 +0200 From: Oleg Nesterov To: Tejun Heo Cc: Christian Brauner , Michal =?iso-8859-1?Q?Koutn=FD?= , Peter Zijlstra , John Stultz , Dmitry Shmidt , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org Subject: Re: [PATCH RESEND 3/3 cgroup/for-5.20] cgroup: Make !percpu threadgroup_rwsem operations optional Message-ID: <20220727173906.GB18822@redhat.com> References: <20220725121208.GB28662@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE 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 Hi Tejun, On 07/26, Tejun Heo wrote: > > > __rcu_sync_enter(rsp, false) works just like rcu_sync_enter_start() but it can > > be safely called at any moment. > > Yeah, I originally used rcu_sync_enter_start() but quickly found out that it > can't be reverted reliably. Given how cold the option switching path is, I > think it's fine to pay an extra synchronize_rcu() there rather than adding > more complexity to rcu_sync_enter() unless this will be useful somewhere > else too. Yes, agreed. As I said, this is just for record, so that I can find this (simple) patch on lkml if we have another user of __rcu_sync_enter(rsp, bool wait). > > And can't resist, off-topic question... Say, cgroup_attach_task_all() does > > > > mutex_lock(&cgroup_mutex); > > percpu_down_write(&cgroup_threadgroup_rwsem); > > > > and this means that synchronize_rcu() can be called with cgroup_mutex held. > > Perhaps it makes sense to change this code to do > > > > rcu_sync_enter(&cgroup_threadgroup_rwsem.rss); > > mutex_lock(&cgroup_mutex); > > percpu_down_write(&cgroup_threadgroup_rwsem); > > ... > > percpu_up_write(&cgroup_threadgroup_rwsem); > > mutex_unlock(&cgroup_mutex); > > rcu_sync_exit(&cgroup_threadgroup_rwsem.rss); > > > > ? Just curious. > > I'm not quite following. Me too ;) > Are you saying that if we switching the rwsem into > slow mode before grabbing the locks, we can avoid inducing latencies on > other users? Well yes, in that another mutex_lock(&cgroup_mutex) won't sleep until synchronize_rcu() (called under cgroup_mutex) completes. > Hmm... assuming that I'm understanding you correctly, one > problem with that approach is that everyone would be doing synchronize_rcu() > whether they want to change favoring state. Hmm... I didn't mean the changing if favoring state... And in any case, this won't cause any additional synchronize_rcu(). Nevermind, please forget, this probably makes no sense. Oleg.