From patchwork Thu Jul 20 16:30:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Schneider X-Patchwork-Id: 13320800 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9EA7BC04A6A for ; Thu, 20 Jul 2023 16:34:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 387D428013E; Thu, 20 Jul 2023 12:34:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3383928004C; Thu, 20 Jul 2023 12:34:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B38128013E; Thu, 20 Jul 2023 12:34:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 0B79028004C for ; Thu, 20 Jul 2023 12:34:15 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D18C0B0C7E for ; Thu, 20 Jul 2023 16:34:14 +0000 (UTC) X-FDA: 81032537628.15.E5040A7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf27.hostedemail.com (Postfix) with ESMTP id DFA1D40020 for ; Thu, 20 Jul 2023 16:34:12 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=djwRwyoR; spf=pass (imf27.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689870852; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=gPdSzcTTJlOeO2aEdgyECLhQy37txJLWdi6TDmez9kY=; b=SGmVuxrsmuDLcEuNjQIDKdQwX+YkGmOVqRX8HNr3gI2dasH5F32gv93atXi3RFD/LWZeU6 6KwCyjfbDcWc2fOxu+Cko2nJvDQF3VqhZ1b8t2XzH1o4tjEQb9PSifYt1G7WpkLf1hy9sQ xYRcC5wnEXytwZg3a2UmcanrkK0wzek= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689870852; a=rsa-sha256; cv=none; b=AQlCeA0aX0MXTNd8NiqeNEXorNys5CaL8zoLJ9vhQc8KJdQXtb5FBLgRcfeWap4GXarXI1 nI7bls6wOMoNMzNDFvmhbuvps32oWTQIxfsbPQwkyFt6rFxWQAEdfuXDxWB6jIdqaNnaOL TVs23M++An3CTzruEBAO0ZIOxdjOClc= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=djwRwyoR; spf=pass (imf27.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689870852; 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=gPdSzcTTJlOeO2aEdgyECLhQy37txJLWdi6TDmez9kY=; b=djwRwyoRT4WBUlXX5F+QuYV/5Oo8VHV8+ZA2T1d4Bn3OxZW/wZbbtOEmBgsHyZr9dya+i9 6hCXz8OxlkYgsku+TWVuFaCg5Crl4eMjDPyswWwSD26caHOL/pLzL1SGCjubgxaF1TaJ5v O6qMRxE35rhDtVJiHPvrH1OSUxDkCoA= 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-230-kFK-c7oyNgC289gF1X8KZw-1; Thu, 20 Jul 2023 12:34:11 -0400 X-MC-Unique: kFK-c7oyNgC289gF1X8KZw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4FA07101A54E; Thu, 20 Jul 2023 16:34:08 +0000 (UTC) Received: from vschneid.remote.csb (unknown [10.42.28.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 29A9240C206F; Thu, 20 Jul 2023 16:33:59 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org, bpf@vger.kernel.org, x86@kernel.org, rcu@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: "Paul E . McKenney" , Steven Rostedt , Masami Hiramatsu , Jonathan Corbet , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Paolo Bonzini , Wanpeng Li , Vitaly Kuznetsov , Andy Lutomirski , Peter Zijlstra , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Andrew Morton , Uladzislau Rezki , Christoph Hellwig , Lorenzo Stoakes , Josh Poimboeuf , Jason Baron , Kees Cook , Sami Tolvanen , Ard Biesheuvel , Nicholas Piggin , Juerg Haefliger , Nicolas Saenz Julienne , "Kirill A. Shutemov" , Nadav Amit , Dan Carpenter , Chuang Wang , Yang Jihong , Petr Mladek , "Jason A. Donenfeld" , Song Liu , Julian Pidancet , Tom Lendacky , Dionna Glaze , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Juri Lelli , Daniel Bristot de Oliveira , Marcelo Tosatti , Yair Podemsky Subject: [RFC PATCH v2 16/20] rcu: Make RCU dynticks counter size configurable Date: Thu, 20 Jul 2023 17:30:52 +0100 Message-Id: <20230720163056.2564824-17-vschneid@redhat.com> In-Reply-To: <20230720163056.2564824-1-vschneid@redhat.com> References: <20230720163056.2564824-1-vschneid@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspamd-Queue-Id: DFA1D40020 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: ihq1a3opemecedihex1f39grxts63bhm X-HE-Tag: 1689870852-990100 X-HE-Meta: U2FsdGVkX18y5TtrkaiJGG+DI/3qMI5I5L+6zCxJT4MQw4cJgHbbVfSR/FIsKWg27CHczHq7bV7ZlSryhoG5BHjFWbhfrmQOZXfXWABByH7tF7vShECFN6ZDvrAuPugyEpRtXiSC+43IeXiknGVnySCuSyDog0zvqrVZp0qmwqYofLY2XjqFAh1J+AnCCdXyi5n2I9iCLLWCiWVILs+Zb4wucApKLMmy/fLOoI1EV4fjY54l3W/N0fUN6d0GkXwzOfVdUMxvFeib5DVgfzqLZV63NmFKBk/qLv8cD1C/EEU6sOJanpOBEjcs2AbjBF6AUeQf3i7/hIn4WkhwMkiN+46WVMpCAz79Ut+zAFEpZ5Gi964cOo3ZEhTynyykZ2o5BbYCFmsTC+Jb4+l6jf5PbfC7k7LZRMKeTK+80OSitFHnvqZwe60D2CieN7ZPFTuPoLq++m4+zaursMuP3wBFwvpYqtlfYCW1CWmDcrVi7NG9riEI83IVEqIFiB9U4M3f6zryfP1QOExiV2Xh/Yka1vPWfZ5WVFliOYT91yDi7Z6sEKW9ikPG4MEkvMOpF5jMGSRaFeNhZUbY5qNaq4BsaLiyLTM5Ku0mLjYoSl7spoFDWfpcbagEBQgEZbncdODnwpHil3wFl8n21TbTL+cBGh55U3yYejyQedELyglr7hEcSMaNNehmUJUMdUogeisCv15XiY9tVfkJQxFkoXrpsFZF03rzYMKPBFNeQnhKufVXD8B+Bq7n7bnq5f72MBgWWcrawTFZ1C3qeDliKWcLaEdjpRF/fsyrweZva2X471MA2gK2TgAe4D0dONx13yzMUhraDb/fsTfOon8ejSZEYvMCxLeUGo6RHPJo5XCLJGdFflWC/BfHaSGtB9TmdUiYbdbYJKjp3SFPNmIa83gs331/2EuV9lyqBFjWE6JKVPVqRAResdkKx7o9EcW2ChswnddgkeM6WZm1yl66GKj 7/sC83pt DqbcuUb5K/TXG6YI/ksrZqJBT/IQXeuwvR2ZpCfY4Z2GGC/aNat51zTiTHcakeKRag0ahHuc0RJHanC/HWghay23zjf3u1t9FrKPdFqqXeWIzxrrF530Da6/kpK67K2zKmaiZr8RR34AooBiw/+mfTpDX4bmoLl654qFS1JgbBRD/1UwmfYqQgDUi+rUVtdKjH4XS/HPjv+u4qFYJmFbxKHY7K9o6zDY0WCJNqC7w3CKYVAlq9T30IvlnC9u+X4Ch96Kz2eJU5of6xh8zQq+OGxc8yePIxjfk/BZQDcDCUotF7wNKUsdn/bNZeQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: CONTEXT_TRACKING_WORK reduces the size of the dynticks counter to free up some bits for work deferral. Paul suggested making the actual counter size configurable for rcutorture to poke at, so do that. Make it only configurable under RCU_EXPERT. Previous commits have added build-time checks that ensure a kernel with problematic dynticks counter width can't be built. Link: http://lore.kernel.org/r/4c2cb573-168f-4806-b1d9-164e8276e66a@paulmck-laptop Suggested-by: Paul E. McKenney Signed-off-by: Valentin Schneider --- include/linux/context_tracking.h | 3 ++- include/linux/context_tracking_state.h | 3 +-- kernel/rcu/Kconfig | 33 ++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/include/linux/context_tracking.h b/include/linux/context_tracking.h index 8aee086d0a25f..9c0c622bc27bb 100644 --- a/include/linux/context_tracking.h +++ b/include/linux/context_tracking.h @@ -12,7 +12,8 @@ #ifdef CONFIG_CONTEXT_TRACKING_WORK static_assert(CONTEXT_WORK_MAX_OFFSET <= CONTEXT_WORK_END + 1 - CONTEXT_WORK_START, - "Not enough bits for CONTEXT_WORK"); + "Not enough bits for CONTEXT_WORK, " + "CONFIG_RCU_DYNTICKS_BITS might be too high"); #endif #ifdef CONFIG_CONTEXT_TRACKING_USER diff --git a/include/linux/context_tracking_state.h b/include/linux/context_tracking_state.h index 828fcdb801f73..292a0b7c06948 100644 --- a/include/linux/context_tracking_state.h +++ b/include/linux/context_tracking_state.h @@ -58,8 +58,7 @@ enum ctx_state { #define CONTEXT_STATE_START 0 #define CONTEXT_STATE_END (bits_per(CONTEXT_MAX - 1) - 1) -#define RCU_DYNTICKS_BITS (IS_ENABLED(CONFIG_CONTEXT_TRACKING_WORK) ? 16 : 31) -#define RCU_DYNTICKS_START (CT_STATE_SIZE - RCU_DYNTICKS_BITS) +#define RCU_DYNTICKS_START (CT_STATE_SIZE - CONFIG_RCU_DYNTICKS_BITS) #define RCU_DYNTICKS_END (CT_STATE_SIZE - 1) #define RCU_DYNTICKS_IDX BIT(RCU_DYNTICKS_START) diff --git a/kernel/rcu/Kconfig b/kernel/rcu/Kconfig index bdd7eadb33d8f..1ff2aab24e964 100644 --- a/kernel/rcu/Kconfig +++ b/kernel/rcu/Kconfig @@ -332,4 +332,37 @@ config RCU_DOUBLE_CHECK_CB_TIME Say Y here if you need tighter callback-limit enforcement. Say N here if you are unsure. +config RCU_DYNTICKS_RANGE_BEGIN + int + depends on !RCU_EXPERT + default 31 if !CONTEXT_TRACKING_WORK + default 16 if CONTEXT_TRACKING_WORK + +config RCU_DYNTICKS_RANGE_BEGIN + int + depends on RCU_EXPERT + default 2 + +config RCU_DYNTICKS_RANGE_END + int + default 31 if !CONTEXT_TRACKING_WORK + default 16 if CONTEXT_TRACKING_WORK + +config RCU_DYNTICKS_BITS_DEFAULT + int + default 31 if !CONTEXT_TRACKING_WORK + default 16 if CONTEXT_TRACKING_WORK + +config RCU_DYNTICKS_BITS + int "Dynticks counter width" if CONTEXT_TRACKING_WORK + range RCU_DYNTICKS_RANGE_BEGIN RCU_DYNTICKS_RANGE_END + default RCU_DYNTICKS_BITS_DEFAULT + help + This option controls the width of the dynticks counter. + + Lower values will make overflows more frequent, which will increase + the likelihood of extending grace-periods. + + Don't touch this unless you are running some tests. + endmenu # "RCU Subsystem"