From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EB1AC19F28 for ; Wed, 27 Jul 2022 18:42:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234538AbiG0SmR (ORCPT ); Wed, 27 Jul 2022 14:42:17 -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 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.