Received: by 2002:a05:7412:8d1c:b0:fa:4c10:6cad with SMTP id bj28csp515012rdb; Wed, 17 Jan 2024 08:45:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IHrwFA9Y+cHriwU7I+Gp5trioQKhNePesILLl63WbsFOMhEtmjgoN44q9bg8gOup2KKa9bT X-Received: by 2002:a05:6a20:9750:b0:19a:757e:f11c with SMTP id hs16-20020a056a20975000b0019a757ef11cmr7685590pzc.51.1705509935503; Wed, 17 Jan 2024 08:45:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705509935; cv=pass; d=google.com; s=arc-20160816; b=WXvuVBI4QFxR+XD4eG/LJuy9LIhfXifkNqLg2+yabxYynr+uNoUf5vUCb/acehwoQO LbuYkOwTt0ZmCwRc5TmemQ3WKjktQK3bLCPw+rO/TQUZ/Y0qzN1t3AVhb4bihRiivptv tJnD46oMj3AYgujs8rOvdk3ZHdxfoUJbt2i3+ycIehwu555kb7zUJUVIeXYcm9m1xGYB yGawXZozT1hHN1b//xf/6OybhHpO/YFeTMEwYmuHLBMkFZRxlqNuFMLlALulGSaaa875 mL9+/2saayCFJMblsFquLOJUUC1WN1RZU+bAvJOSImohUJYHSFuZ610+wXfhGCVdxJcL fcLg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=hMKTEJCLgRjbNlvIEToGyQAyufjPtT3IoQqw3muUhg4=; fh=0cYptx2rNTiuaWnhcL0TTYEVszmCn744IFt48f2CUlM=; b=DdAeeOGlj0yGRdiDWvvTICQWVtH6OU3s9rCeeSTz3WZsqsh5E9Y+iLXNhhr6K8sImu zwegBre5/fqTIcAMX72R5ybkgHkMpb9yqJZYHimISYwfnPdDkpNVnkOAD79Q/TuljbCn vINI9pWuoO2ryTMshwAfcBia20stPvKqvtEpfDyufWSB8spp4kWU0n1VtpwHN3keg9Br mfU7tCdnzRPSlxRfSRYTgAQfg4xwk3xWqlg+YHkslxunL5z7SoNSbJ7o9aErUmiqCaGp WH6vu5ma+7VrOvighxXzDYGmJeQsUTn2+aYhQt1viykiSgRLC3IGzleg0Qhyk0/jB0Th z4Gg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GDGzkdlQ; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-29223-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29223-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id w17-20020a1709029a9100b001d4bb7bf9fasi13335279plp.602.2024.01.17.08.45.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 08:45:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29223-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GDGzkdlQ; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-29223-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29223-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 2F5C3B27528 for ; Wed, 17 Jan 2024 16:36:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1EEFA22615; Wed, 17 Jan 2024 16:36:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GDGzkdlQ" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1EB2224EF for ; Wed, 17 Jan 2024 16:36:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705509377; cv=none; b=FmGGA9+OYSDPY5HuTaiD96KfH1nux3+Xm/3DcwohaNKfG0KMY6V2v982Wqiw8E5MYtTN2jn6Qh7tOQ72ii8tkYfedvL3p8o64TMEsfy5GQjc63leXDPh10B9dh5QQQ1Z8wfBCc8jbxjrF5wy0DAIzgVsjr0n4hauEJQocF4pAv0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705509377; c=relaxed/simple; bh=T/btiksz2pjdc/htwRedVgNxpGRbSjdss4lHcMx0Ds4=; h=DKIM-Signature:Received:X-MC-Unique:Received:Received:From:To:Cc: Subject:Date:Message-Id:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Scanned-By; b=CloCn1Y6dmOIn9B/gnlIsZySIZvut7UnhuJyMCdsevYx6ozCUnBE0cUG9Q44FDd2QIn5PRdtPyHSer+nnbo8xAaDELRRyg39Pn/mKwnqYQrPMK+3TRfzTDdVf+8vu4O3ab3uShWBRQMAbZBLG/MYVy2Ie/Mak2wJLch1JcpEoW4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=GDGzkdlQ; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705509374; 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: in-reply-to:in-reply-to:references:references; bh=hMKTEJCLgRjbNlvIEToGyQAyufjPtT3IoQqw3muUhg4=; b=GDGzkdlQtqiQPd72MkC+Si9H1MpKoURC4x+oXk2PuZnUlgcT4uwPjIfe/viMxdG91AZvMx jQL5N5z+Oxkdqqd3m2vq4el4hP3ry3HyOjIkOp0x52iznc4sHOi47AG1wn5wKacWKB+vIs nVDjUmmRw5cAhnrtyIAPOBdNqF35pyU= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-261-y1ui9Ik_OUyghLE7fiOplw-1; Wed, 17 Jan 2024 11:36:09 -0500 X-MC-Unique: y1ui9Ik_OUyghLE7fiOplw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 11A88383009D; Wed, 17 Jan 2024 16:36:08 +0000 (UTC) Received: from llong.com (unknown [10.22.16.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6F72D1121306; Wed, 17 Jan 2024 16:36:06 +0000 (UTC) From: Waiman Long To: Tejun Heo , Zefan Li , Johannes Weiner , Frederic Weisbecker , Jonathan Corbet , "Paul E. McKenney" , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Davidlohr Bueso , Shuah Khan Cc: cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, rcu@vger.kernel.org, linux-kselftest@vger.kernel.org, Mrunal Patel , Ryan Phillips , Brent Rowsell , Peter Hunt , Cestmir Kalina , Nicolas Saenz Julienne , Alex Gladkov , Marcelo Tosatti , Phil Auld , Paul Gortmaker , Daniel Bristot de Oliveira , Juri Lelli , Peter Zijlstra , Costa Shulyupin , Waiman Long Subject: [RFC PATCH 2/8] rcu/nocb: Prepare to change nocb cpumask from CPU-hotplug protected cpuset caller Date: Wed, 17 Jan 2024 11:35:05 -0500 Message-Id: <20240117163511.88173-3-longman@redhat.com> In-Reply-To: <20240117163511.88173-1-longman@redhat.com> References: <20240117163511.88173-1-longman@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 From: Frederic Weisbecker cpusets is going to use the NOCB (de-)offloading interface while holding hotplug lock. Therefore pull out the responsibility of protecting against concurrent CPU-hotplug changes to the callers of rcu_nocb_cpumask_update(). Signed-off-by: Frederic Weisbecker Cc: Zefan Li Cc: Tejun Heo Cc: Johannes Weiner Cc: Paul E. McKenney Cc: Phil Auld Cc: Nicolas Saenz Julienne Cc: Marcelo Tosatti Cc: Paul Gortmaker Cc: Waiman Long Cc: Daniel Bristot de Oliveira Cc: Peter Zijlstra --- kernel/rcu/rcutorture.c | 2 ++ kernel/rcu/tree_nocb.h | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index 228a5488eb5e..e935152346ff 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -2139,6 +2139,7 @@ static int rcu_nocb_toggle(void *arg) do { r = torture_random(&rand); cpu = (r >> 1) % (maxcpu + 1); + cpus_read_lock(); if (r & 0x1) { rcu_nocb_cpumask_update(cpumask_of(cpu), true); atomic_long_inc(&n_nocb_offload); @@ -2146,6 +2147,7 @@ static int rcu_nocb_toggle(void *arg) rcu_nocb_cpumask_update(cpumask_of(cpu), false); atomic_long_inc(&n_nocb_deoffload); } + cpus_read_unlock(); toggle_delay = torture_random(&rand) % toggle_fuzz + toggle_interval; set_current_state(TASK_INTERRUPTIBLE); schedule_hrtimeout(&toggle_delay, HRTIMER_MODE_REL); diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h index 60b0a15ed6e2..bbcf6f4152a3 100644 --- a/kernel/rcu/tree_nocb.h +++ b/kernel/rcu/tree_nocb.h @@ -1301,12 +1301,13 @@ int rcu_nocb_cpumask_update(const struct cpumask *cpumask, bool offload) int err_cpu; cpumask_var_t saved_nocb_mask; + lockdep_assert_cpus_held(); + if (!alloc_cpumask_var(&saved_nocb_mask, GFP_KERNEL)) return -ENOMEM; cpumask_copy(saved_nocb_mask, rcu_nocb_mask); - cpus_read_lock(); mutex_lock(&rcu_state.barrier_mutex); for_each_cpu(cpu, cpumask) { if (offload) { @@ -1340,7 +1341,6 @@ int rcu_nocb_cpumask_update(const struct cpumask *cpumask, bool offload) } mutex_unlock(&rcu_state.barrier_mutex); - cpus_read_unlock(); free_cpumask_var(saved_nocb_mask); -- 2.39.3