From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 80713322B7B for ; Mon, 18 May 2026 09:50:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779097854; cv=none; b=e35haB0+cqEqgWJenXqJEH2n/USZQY5d0ryZKj7MW8JMZPdQozh5s/58aEqJKWduM6OAIwzio65I+cFRU9o3XTJdZKsCtPLxeMFtAY8DFbsRud+6fHKDjdK9eXvgVP2smSFHJdXuoGjOeJ1AgWQKJoRE42fprIAFvI4+NIwe6d8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779097854; c=relaxed/simple; bh=XWSQwoDFIaH2o1UGbnO7M9TuyMOc7ANs+7v39DOcLXw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SaWLrRbvIGJSrAF2E4Q1+HJ+oQlOc7XBPxC1r4UiASAbwdv/hDAisjc4mhWjoGVs6RYidzV7vRsYFrIptWBnloO5rRWg2JYodYWjCaeMi2i3DMsEuH5awwwYHHxC9doW938NIwNEuKr/sLmA049fKWOKElzVeq4n/fSrWzTGVa4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=K30HU6Xz; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=hCBP/NQu; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="K30HU6Xz"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="hCBP/NQu" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1779097850; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Jc7l/gg80oX0jL/4qJmHKXqxml1Vo+aQQWLxItlgPwo=; b=K30HU6Xz+/81xSNbNLhiKBnmtZnlVx4ZZkYj8p+N3j9jCZDGrl0ecrRjpkwYAG0XckZbm5 5AuzP0jnAQjPItmUOz4BjG0qa7FbDzeZbVx/ZHm4DiFguoYxFa0od3yyXTUtCtZiMqpCv7 hwlIRlsSszyAZVicxFRuHr2fa3RJMtQW5Ai+KNFyHUe3ZETraWqGuiq5zund0mxKLgWpqu R76le1iwJWo6n8QHxrWuZskWIZq7KYoO5duLTDiVmk1eJ1pN3Xm99B+eJvBY1jQS5As1CL UVnJF1AGf/g+U29C/gp3QebIDplFPyMpmHnmRB74fbb4GqC5faP/S2Dc2/jCNg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1779097850; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Jc7l/gg80oX0jL/4qJmHKXqxml1Vo+aQQWLxItlgPwo=; b=hCBP/NQu4Zf+ysJPIP+Wj8MSwDJVODDN5Sy7HUuzAwDy50pUx/VadCw0LQYLcfNEzv7rb+ ws8v6EnW8PTDY3DA== Date: Mon, 18 May 2026 11:49:43 +0200 Subject: [PATCH v3 5/6] vdso/datastore: Allow prefaulting by mlockall() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20260518-vdso-mlockall-v3-5-bf4f2af2b41f@linutronix.de> References: <20260518-vdso-mlockall-v3-0-bf4f2af2b41f@linutronix.de> In-Reply-To: <20260518-vdso-mlockall-v3-0-bf4f2af2b41f@linutronix.de> To: Anna-Maria Behnsen , Frederic Weisbecker , Andy Lutomirski , Vincenzo Frascino , Thomas Gleixner Cc: Nam Cao , Sebastian Andrzej Siewior , linux-kernel@vger.kernel.org, Andrew Morton , David Hildenbrand , Jason Gunthorpe , John Hubbard , Peter Xu , linux-mm@kvack.org, Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1779097846; l=1829; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=XWSQwoDFIaH2o1UGbnO7M9TuyMOc7ANs+7v39DOcLXw=; b=txqlEqpsMZu3yYNsjeo+PZQxSxxMLxOn1RELhIfkP1Q33PdbnPa53tZqehLhcLg0fZEvViCa/ UP+m2x5q3XuAhzPsAELANtmInSGHmsQh8b6E4qHB/Hk3mbwHiQbQkzV X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= While mlockall() is meant to lock page *memory*, effectively it will also create and lock the corresponding page table entries. Latency-sensitive applications expect not to experience any pagefaults after calling mlockall(). However mlockall() ignores VM_IO mappings, which is used by the generic vDSO datastore. While the fault handler itself is very fast, going through the full pagefault exception handling is much slower, on the order of 20us in a test machine. Since the memory behind the datastore mappings is always present and accessible it is not necessary to use VM_IO for them. The data page mapping is now also aligned with the architecture-specific code pages. Some architecture-specific data pages, like the x86 VCLOCK pages, continue to use VM_IO as they are not always mappable. They will require their own special handling later when the general aproach has been agreed upon. Regular mlock() would also work, but userspace does not know the boundaries of the vDSO. Reported-by: Nam Cao Signed-off-by: Thomas Weißschuh Tested-by: Nam Cao --- lib/vdso/datastore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vdso/datastore.c b/lib/vdso/datastore.c index 3381ccf9edb1..3f837cb6a886 100644 --- a/lib/vdso/datastore.c +++ b/lib/vdso/datastore.c @@ -125,7 +125,7 @@ const struct vm_special_mapping vdso_vvar_mapping = { struct vm_area_struct *vdso_install_vvar_mapping(struct mm_struct *mm, unsigned long addr) { return _install_special_mapping(mm, addr, VDSO_NR_PAGES * PAGE_SIZE, - VM_READ | VM_MAYREAD | VM_IO | VM_DONTDUMP | + VM_READ | VM_MAYREAD | VM_DONTDUMP | VM_MIXEDMAP | VM_SEALED_SYSMAP, &vdso_vvar_mapping); } -- 2.53.0