From nobody Thu Apr 9 14:57:50 2026 Received: from mail-qk1-f202.google.com (mail-qk1-f202.google.com [209.85.222.202]) (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 272D735F5EB for ; Sat, 7 Mar 2026 20:07:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772914047; cv=none; b=m47xGey+m5bLbZgtnU0nrIu85WGlptgb7jieU5SzhdWSxodg3YBj8ATRV2I4ZZOorz+oBzaa7uCAAMRTyvcG+FhgFrPBZB/cVyxO32h2SB15095dA+1tKq7hJtLjhieoHWNaaRtTFFNIhUwuGNrz0obQzXSHz1ekzcTE8cQTWeY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772914047; c=relaxed/simple; bh=BkGrTun8zHH+u7e7103bLpgapd4xE9WVaNH7rbsqKcA=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=ZcS6TDS0YNdc3r9WGCILkvlzE3kD5dEmjY8kzLHXLN4pr/ANKjNwGg6TGGgyYhdBknn6taOr+XHxyXbMYdNpgoENbjlr0CTW1a4Qjr8oLHFYYXpjcTTa50o6whH2qEADKtydkbSo8zeuGphw0PJLIyZIqh0SI+PLC0aHEDZ/2Cs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=e1TxH7to; arc=none smtp.client-ip=209.85.222.202 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--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="e1TxH7to" Received: by mail-qk1-f202.google.com with SMTP id af79cd13be357-8cd7c4ab845so171625885a.1 for ; Sat, 07 Mar 2026 12:07:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1772914045; x=1773518845; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=sYuiXhWnCaJ2KfF+7We29QPrJPRhuQtDIksSY7YOpqY=; b=e1TxH7toBt3WXfJUPNOgCR7bRbT/MXkhbPtrxoktmdsOSUbG8SlAKX6qCNFWXTUctd z+gSG1Dp1tooRJvsIvSI1opnCoThgB35z96oNsWModBzk7eX/ivJ3yR+zadpEh76ISUA IMjd32poDweFgvDrSYbfrPJDJBdU7bQr+PJ3BlEpxGA407+WtPMyxLlIdw0fpNkvGWj8 O1uc5qBAMuRoFuR/jdodEhtYt9u1yId+Qf8ZmFEiMF7mu0HFBmbGLjN+8ELb+G6FK7xE r4jRMw1eQhQPDEIootNzllCRv/HYVrbViUcH/T0+T3LFMxU0Egb+jSs9SRMTg3pJOzIE sb4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772914045; x=1773518845; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=sYuiXhWnCaJ2KfF+7We29QPrJPRhuQtDIksSY7YOpqY=; b=Ol63ZUPTn5m2WBVB6L3jrHGvJaEDkmJj2Unch8qKswPZMrzZKt1t3lE1EooSnq/05D pGXq274OldLW9rUIjMAkxBVzC9yw7bXD4TptzNh2jmSNUdCZ5glDk5Afk7ajbAJ7GI+o GspVnqCL6PaYABmYbyRZ7utjOKZBg0C48+vD6JxOHe2ykR30wnlYygbGgA4tJG5Od0Q5 LmHT+fY8w7ENxxPOXrpEZWmBuKLAzQ7e/lVR++lS1Qbli5PqIZvIP0VkZWQsrELhEgSC R7JkGf0aGaWd1wD6TcZ8+STamdhqwYG7455zr1xt2RfLLGmElvqFAtSup32nyA0E9Ubo I5UQ== X-Gm-Message-State: AOJu0Yz2Zo7zbqVZ3InSidt3b/i+CswKrMDyhjcGhiKSX7p86N9LtVid xox3+PrDoWXdqwDs/GoghzuNJI1qU+/9Z9fs7PRW6cp2LVdr1DLdF/aVP56MGcLrJ0q2TMakzfw pdPCwoN5faZ7s9g== X-Received: from qknq15.prod.google.com ([2002:a05:620a:24f:b0:8cd:7a26:dd77]) (user=edumazet job=prod-delivery.src-stubby-dispatcher) by 2002:a05:620a:254e:b0:8c3:7f27:a65d with SMTP id af79cd13be357-8cd6d371593mr825151885a.28.1772914044892; Sat, 07 Mar 2026 12:07:24 -0800 (PST) Date: Sat, 7 Mar 2026 20:07:15 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.53.0.473.g4a7958ca14-goog Message-ID: <20260307200715.1464206-1-edumazet@google.com> Subject: [PATCH v3] eventpoll: Convert epoll_put_uevent() to scoped user access From: Eric Dumazet To: Linus Torvalds Cc: linux-kernel , Thomas Gleixner , Eric Dumazet , Eric Dumazet , Christophe Leroy , Dave Hansen , Kuniyuki Iwashima Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Saves two function calls, and one stac/clac pair. stac/clac is rather expensive on older cpus like Zen 2. A synthetic network stress test gives a ~1.5% increase of pps on AMD Zen 2. Signed-off-by: Eric Dumazet Cc: Christophe Leroy Cc: Dave Hansen Cc: Kuniyuki Iwashima --- Prior attempts by Kuniyuki, in case some background is needed: v2 : https://lkml.org/lkml/2025/10/28/1553 v1: https://lore.kernel.org/lkml/20251023000535.2897002-1-kuniyu@google.co= m/ Thanks ! --- include/linux/eventpoll.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/include/linux/eventpoll.h b/include/linux/eventpoll.h index ccb478eb174bc2e4454cee59f805f10cfd5bb5fb..ea9ca0e4172aab13b8e576258e1= d457a913dcebf 100644 --- a/include/linux/eventpoll.h +++ b/include/linux/eventpoll.h @@ -82,11 +82,14 @@ static inline struct epoll_event __user * epoll_put_uevent(__poll_t revents, __u64 data, struct epoll_event __user *uevent) { - if (__put_user(revents, &uevent->events) || - __put_user(data, &uevent->data)) - return NULL; - + scoped_user_write_access_size(uevent, sizeof(*uevent), efault) { + unsafe_put_user(revents, &uevent->events, efault); + unsafe_put_user(data, &uevent->data, efault); + } return uevent+1; + +efault: + return NULL; } #endif =20 base-commit: 4ae12d8bd9a830799db335ee661d6cbc6597f838 prerequisite-patch-id: f6002c357582927a383603a22e69bc0d7a5b9528 --=20 2.53.0.473.g4a7958ca14-goog