Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp246138rdb; Thu, 1 Feb 2024 07:27:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IFCNojk6KbBCbhoR1vAb8eXQTZYqwVR2TFeArD7L3mKuxuIH0AYlFGmWozkAaSzcRP1qsJJ X-Received: by 2002:a05:6a00:d52:b0:6db:dd2d:b4e2 with SMTP id n18-20020a056a000d5200b006dbdd2db4e2mr4634582pfv.8.1706801263605; Thu, 01 Feb 2024 07:27:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706801263; cv=pass; d=google.com; s=arc-20160816; b=yr2KW6FrFkTZlAWxRJX3WFY0r2e/lY6M9V4JTA+yp3tlRpAJJQWG8sMMWAooYikuEW nBgjC0ijS2M5wPLhVGK3CkhsTMcN7MLvpoL/OQXDqJYaUu/oQ2ypWWMnmfSgW67g/fuh 5yWviUxqhzqrcfKm6rb7PIIuc/2iWdhZbitvsKkGv3MiYooTc2Hzb5JPCzI+X310JY7m 1Tng2E1MAT/88cPgkEKPS+5W+LIpUobVm+iFIwicnxv2lwZVTuCttU1iZjrrW5CYS/6M M1pzCgGG7eM6e34AoTe6Mvb1kkHn16DHNFRiWW0doxXltKsKcIIrKvz1jz31P34rTZOj G40A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=88ASP96tK3dRScHGmOsrV534zaqeW95BMrBBjShGzmM=; fh=TRixvbFwOMiIsNdO7vV07xVjsg/WDKg/GG6j4Ju81ys=; b=fux9arMqchirVYg1ZhRvULmGTyn2PGwk+dF5YH3JMzoKFj8L7whM5REVryucpgRMwx ElYYwjXCP1NLZnJxJVnFdtdLb7zOhIOfWJZ7tB7clH86P+7i3tkY+8M0NIucIVduVAgc aOJYPhKJPJ0F4kAZIQGmnRdC3Muc4ae0wZUTIbS/Iym1Py0NmiIpKq2FcTM9UI/6u4u4 WAd9NYMO3vZtK0tOgFaU5dPQlvqcgRbO4VHXTlnLPK91Mzl7hnHGwt0Hnjyr7ZR/WfUC alzawdbOut+hYFMex9E3170DgF/XfHiTcot7+qvFKbZ8fMyj3/U3PlIiFE1JLAbMEeJO uEcA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=proxmox.com); spf=pass (google.com: domain of linux-kernel+bounces-48392-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48392-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCUC/gyKO8GGJfrKkvIXEFhwwXpY2XMAC67Ue0n36yKb6y/J5gbyddalyS9xwBSL4DFDucI7BPxGf7PhQ+dtTGRit2VOOyCy/vgEE07aTw== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id z16-20020a62d110000000b006db625e59d8si12080108pfg.173.2024.02.01.07.27.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 07:27:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48392-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=proxmox.com); spf=pass (google.com: domain of linux-kernel+bounces-48392-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48392-linux.lists.archive=gmail.com@vger.kernel.org" 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A144529545B for ; Thu, 1 Feb 2024 15:24:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 447A815DBA1; Thu, 1 Feb 2024 15:22:22 +0000 (UTC) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (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 11B7A15DBBD for ; Thu, 1 Feb 2024 15:22:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=94.136.29.106 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706800941; cv=none; b=CH3eekubq2LABqlAyUcP9KREMwrvLR774y1csgNu0hzghGgwYnA6NbGW+F/Ulm660clDcq1PXdcX+oZAUBkkChK0zrQ4+WzdzotcpJNxPtXPBxJVeQ6fv4Xa+D35gnhR9Bu8jL4NYPMQyp8GD9kUoyBsk4YK5X0G7gg7Nj3B4zA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706800941; c=relaxed/simple; bh=/fNW+EnrstF3l6Tjhf3Juk+33vhljOeeF3e/iB7fpLg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=K6sauhZCMESpUnWxNWrBQycdjLhpRh1tJ9pgWeeqMa/UCAkTKUkWOp5iPAg7YJoggNbk27I5gzdGYLxax3rXWiWWBiEcXEOO8n/GZvybsdtPmi81cqZHFBYdwVOh3/Hely30l7ix9FHIPKrwb5FOX4ajbkfp65RwkRGA2JebFXY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=proxmox.com; spf=pass smtp.mailfrom=proxmox.com; arc=none smtp.client-ip=94.136.29.106 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=proxmox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=proxmox.com Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 0410E41ED5; Thu, 1 Feb 2024 16:22:13 +0100 (CET) Message-ID: <34292692-67e9-4132-be1c-eba79dd3a84f@proxmox.com> Date: Thu, 1 Feb 2024 16:22:11 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] sched/core: Drop spinlocks on contention iff kernel is preemptible To: Sean Christopherson , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot Cc: linux-kernel@vger.kernel.org, Valentin Schneider , Marco Elver , Frederic Weisbecker , David Matlack References: <20240110214723.695930-1-seanjc@google.com> Content-Language: en-US From: Friedrich Weber In-Reply-To: <20240110214723.695930-1-seanjc@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 10/01/2024 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. > > 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. I've been testing this patch for some time now: Applied on top of Linux 6.7 (0dd3ee31) on a PREEMPT_DYNAMIC kernel with preempt=voluntary, it fixes an issue for me where KVM guests would temporarily freeze if NUMA balancing and KSM are active on a NUMA host. See [1] for more details. In addition, I've been running with this patch on my (non-NUMA) workstation with (admittedly fairly light) VM workloads for two weeks now and so far didn't notice any negative effects (this is on top of a modified 6.5.11 kernel though). Side note: I noticed the patch doesn't apply anymore on 6.8-rc2, seems like sched.h was refactored in the meantime. [1] https://lore.kernel.org/kvm/ef81ff36-64bb-4cfe-ae9b-e3acf47bff24@proxmox.com/