From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 0723F2DF12B for ; Fri, 14 Nov 2025 18:54:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763146469; cv=none; b=oFIIfkT+TA/4XuTQDOtXWHazM87o/d/CMjgKagmUTD94iHI+Cea+gY1jJEvmo9zEb+a+72L5ZqSXYSlChwABbEF0+1+uGSv27CZR7T+ahSSK3U6nWNJ+1dTilczsEkyeWF8UIsvz55TKUeQ8e+dbrbJBEswiN1YkXtmLblUQFCo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763146469; c=relaxed/simple; bh=WupAXsUwOqm9N8aItz9IuraBGtbt6+1ogwOCXXBfEo8=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=j3wVb/FcGCDX3mw+nIrXF9AM/QJ9GsecJ3sZUiJR4iI34ErSV0RmKNaYIT9Fki0tZ8T8sq7S3yd//di8yxbsTw2g97TCxqPExS6iIm45zGtHiUILicgwV4FObYIK8FvDrl41WRmijHSHc2TmfAnf+d+wuXBRCI8sGhu0zzPgVAo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=aEL+6eZl; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aEL+6eZl" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-47774d3536dso20353995e9.0 for ; Fri, 14 Nov 2025 10:54:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763146466; x=1763751266; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=su/3DTeyEOfiuZEhYMJ4B5Ixwohi82QW36MCAtfZ6Mw=; b=aEL+6eZlK4ykBqffMe3TD/VnapzlEsaQbb0yxH2J1mLnTVjO5d8Hc6pBR4rbiXLHmH PPQBKL54zRgwtoBoIz1mFkZhb/TdhlpVMctKC1YKQahnWZR2RAStF2MtBXtO63ztfOqt tu9QFdgEJ4gaZ8lDw3xeiatveZhFEEdrpOo2duE7o7Ybwz9EjXRGzU1UOz0UYExB0Qfo BSlR8vWJKbNFxIE3Vzw6dRL6W5YwM3iRo9IGH3aWWWzvD9QUJ1PRgXexri4LHBp7jANG QbRqJ2KmE0zMMjtnGGgQtz1UsCMZlcaiUOMzGUb5/pBbvpkYuxpWPycoOfySc5MxHoHE 8L5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763146466; x=1763751266; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=su/3DTeyEOfiuZEhYMJ4B5Ixwohi82QW36MCAtfZ6Mw=; b=OuO/7a2ePbVP9OTpj7S9YboDE/iHeh+C3hO3DPqv1ERWjjt7yXO1VTOCppgDhHSvUB 8fQJczmSp5lHSl++BpMIku9t/7G2q9D8B6nAmgkSGDK2H2NkGAbizOP1FiH10qvUiz/X fQc9ON5QJYJZ+MVeoXTc7NUERiZ48vu2v6Q82Cdwa12kjdFx4iHVKxz/nCXhLroo6Y1H i5BryHfwxZBmLw3O6enznEA4Dmw0YtyBYRPrJ0J9mqU74qiIAY6qL2T3whvFwgyC+OJT xPFtoJzreygzXx0PL3w/BqW1Yno5BCtUspfdrAFpVlEH9irrEj+omyvFn9ARQbWeA+C2 X10A== X-Forwarded-Encrypted: i=1; AJvYcCWkiebgdO/Z+Bk8d28LS7M4ZVK7LqDwqgeo05Jtxib/aZoyd5GFzbyOzZpyFQ7GPcI8LiRLRaKWkKEwfYg=@vger.kernel.org X-Gm-Message-State: AOJu0YwR0gk/zBQmdMrZQCL1rNhpau5nCiUwzMpd595QRVAOKYNvwX1t QK2SQfPkSpIIlJLAWqspnu9u2Vn/TMG4Y2jpn2nosZfaXwlGD39om6Y0 X-Gm-Gg: ASbGncvAe6Kb6j/NPd9hLJr6LCz/NZaT9awa6VPgUVua9MriKDTgD7MreA7/vvNVAvY bvnU+s6mnfrgjCeD4HpOFQyZFU0s5J+3hQie+NTZArPYIcZNo0BD8Lq7EgqBkRf2tajE+KTp4B+ /wW54y0R0+OW/j5Lw+UPVEpEKfRIj6gDsHCxu33MRwnsBvw1KFg0MJrpgmGZ4DUxB0OE8FXj4Jb yAtu3UVDSimWvZs76gb/JM8ONpHI8rdtV6tzrCJh4icMZuPWKXfkqqjtAPclJYCw2fBkfkGVZiX fO9M0lvpRFgCJpKfj0ZXb3exkD8LgrKL+oDrxbgrBfdvr0W+8Tr3m7IolI3ZLRw2IFVK3l6LJ2s UsY3JMgWBdmiaGemz3MBCKt30+wZSVipMZ/OA1/OBRo0nJIl+gTf7SWeFsTTOU73jKfgaqAA65r RhyfwgugB1twY3TE85asFBOSsVrqacLi8KytdVuDIAgOOFDn0z5bfyRktKje/oBnY= X-Google-Smtp-Source: AGHT+IEZk9USqhXcykeqQxv6BBqPJ+Ckp0QcbH6DW0s45+kWxw1D0bAUF1znH554QTmUBF8i4qIoUw== X-Received: by 2002:a05:600c:6002:b0:477:8895:303c with SMTP id 5b1f17b1804b1-4778fd807f3mr32662695e9.3.1763146466154; Fri, 14 Nov 2025 10:54:26 -0800 (PST) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47787ea39ccsm156460775e9.15.2025.11.14.10.54.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Nov 2025 10:54:25 -0800 (PST) Date: Fri, 14 Nov 2025 18:54:24 +0000 From: David Laight To: Jon Kohler Cc: "Michael S. Tsirkin" , Jason Wang , Eugenio =?UTF-8?B?UMOpcmV6?= , kvm@vger.kernel.org, virtualization@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Torvalds , Borislav Petkov , Sean Christopherson Subject: Re: [PATCH net-next] vhost: use "checked" versions of get_user() and put_user() Message-ID: <20251114185424.354133ae@pumpkin> In-Reply-To: <20251113005529.2494066-1-jon@nutanix.com> References: <20251113005529.2494066-1-jon@nutanix.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 12 Nov 2025 17:55:28 -0700 Jon Kohler wrote: > vhost_get_user and vhost_put_user leverage __get_user and __put_user, > respectively, which were both added in 2016 by commit 6b1e6cc7855b > ("vhost: new device IOTLB API"). In a heavy UDP transmit workload on a > vhost-net backed tap device, these functions showed up as ~11.6% of > samples in a flamegraph of the underlying vhost worker thread. > > Quoting Linus from [1]: > Anyway, every single __get_user() call I looked at looked like > historical garbage. [...] End result: I get the feeling that we > should just do a global search-and-replace of the __get_user/ > __put_user users, replace them with plain get_user/put_user instead, > and then fix up any fallout (eg the coco code). > > Switch to plain get_user/put_user in vhost, which results in a slight > throughput speedup. get_user now about ~8.4% of samples in flamegraph. > > Basic iperf3 test on a Intel 5416S CPU with Ubuntu 25.10 guest: > TX: taskset -c 2 iperf3 -c -t 60 -p 5200 -b 0 -u -i 5 > RX: taskset -c 2 iperf3 -s -p 5200 -D > Before: 6.08 Gbits/sec > After: 6.32 Gbits/sec > > As to what drives the speedup, Sean's patch [2] explains: > Use the normal, checked versions for get_user() and put_user() instead of > the double-underscore versions that omit range checks, as the checked > versions are actually measurably faster on modern CPUs (12%+ on Intel, > 25%+ on AMD). Is there an associated access_ok() that can also be removed? David