Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2129204lqo; Mon, 13 May 2024 08:35:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX0BwBsULLdTpfO7MzIrVsFaaMrCkflLk8B91E5I3adboPB+CZ/Ut7jlRJHLz7lBOZqXma6T2UZGQ7H9O5qm+Iloh9Asb+v+54GwwEguw== X-Google-Smtp-Source: AGHT+IEI7rqX2ittQwLLH4S5wZwKOYFZVbJG+NYidlUgZWV0aExOS+BiznqqShH8huI8jU1bn2r5 X-Received: by 2002:a05:6a21:619:b0:1af:7bbc:a163 with SMTP id adf61e73a8af0-1afde0cd68bmr10772044637.18.1715614531440; Mon, 13 May 2024 08:35:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715614531; cv=pass; d=google.com; s=arc-20160816; b=fmNz2MaZ0kZz0C3Gzdc3of/+WrT5LgztCymmIHjj0/HVcNcd1lhN/fEaRYYQv5MiOo MKUnwBlHwVTixEpDMPQtSaaBv6OrWrEH8sD5jzZ1W6vKNce0OSm4ADr8zpXR0GUTknZE Q6QHvgykLLAQKe5TXLm5RpfC7ojm3Ffc9eoKzFftTJlxD+7U/cO+NLgpyh13CLaj5Yc2 NP9k3wTwz3mqc41Pqn6S2qlpMRywWml9hhlCp+ymN3jCon7VhXL4LML7Ubhxbr0tihWA 6p020mf9m62Oq+wKb+OLN0no5bCmsal21Kq9cBtezSnq7MbgBMMWIIt//oKSe47bOjSu Yvjg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=WMgvtz2/Q+j3YoQLH1bJjltvWBvO9e9H4j6SuRwFAj8=; fh=CxsCt0W6MvCHrUBUTTlhMVjkz4oYoC8swoHkfdX9zGA=; b=vNTGM4E3ZYDM+5NggfqKTUr8FUwcW926tYbpvGQJH0cTBqqYpPJGt/IXb3KJp4GSbT 6yCUnGVMPyAa89u1BZ7qmON1hmws/B0gZvWt+Cy4sEryhj+qr9U3pd6eMhic1KNXQlaj WX2M9dm4y9ZT4zvqjz+JbSbSnmlGEwgSI+dHnn4I2oiaNQi5Zm8pDVeyyGoQzoDMqPrF FGNe7H13Na9o8zCEGSTGC1zWm7em7MBYsyRo/IFP9l42Ax2DzqAJsKI4Wum6HlgPx67m LqKXYWuaOkLfAoXI0B2eWpg7tB4+5QUk/OqILsYxvBRr2AivZyp+kjjY4pPau5AACzwm LbiQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=PJOVXwFX; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-177759-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177759-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 98e67ed59e1d1-2b628fb9b18si11492802a91.128.2024.05.13.08.35.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 08:35:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-177759-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=@google.com header.s=20230601 header.b=PJOVXwFX; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-177759-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177759-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 8C8FFB2322F for ; Mon, 13 May 2024 15:34:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F2B1E156C65; Mon, 13 May 2024 15:32:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="PJOVXwFX" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3CBF156861 for ; Mon, 13 May 2024 15:32:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715614323; cv=none; b=Fd526bhjh0cpKYPEu6Nl73WvTdzoGYitJFxBWrEZQDHmLFZBd9p5zdv00Tc2J7vkOpy120dOZ6JqJA8oCPfPZ4E2NPRW1ZkIxsBAGgmswbcCJgDMqHAaNcGmMt3yfTpnBvon+MkHY6kghiKjiIbyLp+8cEve6b2J+UFtYa49qHw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715614323; c=relaxed/simple; bh=9XgQabjgGAZzJXK2jlYawVYFy2EhNnFwkqg78gYlNhs=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=G/FCjWJKPx/2wkJwlHKsh5YY/g6wPh+Qtt0fMxuUkV8EBNnzyYy7BllgaZLWW8pgxwVGCG0M05uc34uraYz7j6EUKMMGpHPoR6XsfVsgEHdxMWLC++PmgPOfJwx1sNew/NvccBvcYuSZiXskEvkwHL3hg30zozJlofUQ/ZdoR6s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=PJOVXwFX; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-de6054876efso8934330276.2 for ; Mon, 13 May 2024 08:32:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715614320; x=1716219120; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=WMgvtz2/Q+j3YoQLH1bJjltvWBvO9e9H4j6SuRwFAj8=; b=PJOVXwFXmFCkhzmsox0fcmiNV13775ihOSOjxf0CJ+/lFHYuVxvlv9d6gKuHdv7GyW nRHj4lg46W05wcyOaATBCnwQZYfgYZyLKsSdPd8wwjBITrqPXWMYWcoVsBoCgYVtmvJd hiOmXRzwOkLl+76Iqed7hkEWOaX6W2gZonvngTzB/iECgc/dbVruLGW2YDQZzjB3V18B njp6MKabddBmAlTjCw41O7y81LI3oEzhucC0oCko9dxDuIVPp5K9PHrIslTztwprJSUq ixBmGgts/jyZxqFBAhAYYlM1dtLgWbgveBNrunCex4clKG+3XN4clrMc2oXhyessWbfP AcWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715614320; x=1716219120; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WMgvtz2/Q+j3YoQLH1bJjltvWBvO9e9H4j6SuRwFAj8=; b=k5MQm5znQuWjV4atpbkWi3NmLlmH2R8PmD2dow5B2hbc4dgT4EEwrlA6XaAGMlGX3r sq7MKPcgMnWAJx1jl1qRZ5KqETC6q+E+Gc0fm2gBlR1MDd7fbFYIaF4dx0JArfic+LeV kKSa/psrsSv0Ku7GM8QirtVtiQVW2kJ0axHAk4YhtYRp3rKoyj/dTrIE4hlCjaImutPH rwxbXDoJkEqbZ/H0s6pL9AofYT9goP030OyLkNhLvzTRLkP60Ap3HYApUb9iEvjNyQ61 EnnekyN2swJqJIWMHtJNhtdvgUKcgXvAMkPuoxPIdxLF7t4vrhGw5/oKn+Jx/1ixCV14 cLRQ== X-Forwarded-Encrypted: i=1; AJvYcCXr7rlBc9Bfk9FkgWptx0HzCnUzn+l49PQogXg114Q/DywNcc/zoQIj0DUEiY+XCGbQfjjMGuUr6LOjZylTsq6w8KrJtMEtTbKjRbmf X-Gm-Message-State: AOJu0Yxl0TmdaAoBc4uE2vUrdwELb2ku5Es/7LW+4+qdMVDiO+4wTDYC alc+HrHDP4Y6ueNkJ+9jQvaiggPJwOyU3ZdNSv9uPiIZ9KGsB5Y8LoREv/jqsf/6xCuG+eabzKi 6qQ== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:102d:b0:dee:6802:dc49 with SMTP id 3f1490d57ef6-dee6802f337mr1771991276.1.1715614320675; Mon, 13 May 2024 08:32:00 -0700 (PDT) Date: Mon, 13 May 2024 08:31:59 -0700 In-Reply-To: <22def35f-5b8d-4424-a03b-c90e9174a14d@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240110214723.695930-1-seanjc@google.com> <22def35f-5b8d-4424-a03b-c90e9174a14d@redhat.com> Message-ID: Subject: Re: [PATCH] sched/core: Drop spinlocks on contention iff kernel is preemptible From: Sean Christopherson To: Paolo Bonzini Cc: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , linux-kernel@vger.kernel.org, Valentin Schneider , Marco Elver , Frederic Weisbecker , David Matlack Content-Type: text/plain; charset="us-ascii" On Mon, May 13, 2024, Paolo Bonzini wrote: > On 1/10/24 22:47, Sean Christopherson wrote: > > Use preempt_model_preemptible() to detect a preemptible kernel when > > deciding whether or not to reschedule in order to drop a contended > > spinlock or rwlock. Because PREEMPT_DYNAMIC selects PREEMPTION, kernels > > built with PREEMPT_DYNAMIC=y will yield contended locks even if the live > > preemption model is "none" or "voluntary". In short, make kernels with > > dynamically selected models behave the same as kernels with statically > > selected models. > > Peter, looks like this patch fell through the cracks. Could this be applied > for 6.10? > > There is a slightly confusing line in the commit message below, so that it > reads more like an RFC; but the patch fixes a CONFIG_PREEMPT_DYNAMIC > regression wrt static preemption models and has no functional change for > !CONFIG_PREEMPT_DYNAMIC. > > > Somewhat counter-intuitively, NOT yielding a lock can provide better > > latency for the relevant tasks/processes. E.g. KVM x86's mmu_lock, a > > rwlock, is often contended between an invalidation event (takes mmu_lock > > for write) and a vCPU servicing a guest page fault (takes mmu_lock for > > read). For _some_ setups, letting the invalidation task complete even > > if there is mmu_lock contention provides lower latency for *all* tasks, > > i.e. the invalidation completes sooner *and* the vCPU services the guest > > page fault sooner. > > > > But even KVM's mmu_lock behavior isn't uniform, e.g. the "best" behavior > > can vary depending on the host VMM, the guest workload, the number of > > vCPUs, the number of pCPUs in the host, why there is lock contention, etc. > > > > In other words, simply deleting the CONFIG_PREEMPTION guard (or doing the > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > This should be "deleting the preempt_model_preemptible() guard" given that > the patch does delete CONFIG_PREEMPTION, and only leaves > preempt_model_preemptible() in place. Note, this version won't apply cleanly, v2[*] handles the code movement and still applies on Linus' tree. [*] https://lore.kernel.org/all/20240312193911.1796717-1-seanjc@google.com