From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B1EBC433E0 for ; Thu, 7 Jan 2021 19:00:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 37AB123432 for ; Thu, 7 Jan 2021 19:00:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728302AbhAGTAF (ORCPT ); Thu, 7 Jan 2021 14:00:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726319AbhAGTAE (ORCPT ); Thu, 7 Jan 2021 14:00:04 -0500 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 400F6C0612F6 for ; Thu, 7 Jan 2021 10:58:27 -0800 (PST) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kxaUC-0086S5-9C; Thu, 07 Jan 2021 18:58:16 +0000 Date: Thu, 7 Jan 2021 18:58:16 +0000 From: Al Viro To: Linus Torvalds Cc: kernel test robot , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Peter Zijlstra , LKML , lkp@lists.01.org, kernel test robot , "Huang, Ying" , Feng Tang , zhengjun.xing@intel.com Subject: Re: [x86] d55564cfc2: will-it-scale.per_thread_ops -5.8% regression Message-ID: <20210107185816.GJ3579531@ZenIV.linux.org.uk> References: <20210107134723.GA28532@xsang-OptiPlex-9020> <20210107183358.GG3579531@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 07, 2021 at 10:47:07AM -0800, Linus Torvalds wrote: > On Thu, Jan 7, 2021 at 10:34 AM Al Viro wrote: > > > > I'm not sure it's the best approach, TBH. How about simply > > for (walk = head; walk; ufds += walk->len, walk = walk->next) { > > if (copy_to_user(ufds, walk->entries, > > walk->len * sizeof(struct pollfd)) > > goto out_fds; > > } > > in there? It's both simpler (obviously matches the copyin side) and > > might very well be faster... > > I started doing that, but .. Nope. > > It's not copying the whole entry. It's literally just modifying one > 16-bit word in each entry. > > Now, the "whole entry" is just 8 bytes, so it's possible that it would > actually be faster to do a copy of the whole thing rather than write > just the 16 bits. But I got very nervous about it, because I could > easily see some threaded app actually changing the 'fd' (or the > 'event' field) in place (ie writing -1 to it as they close and re-use > it) Point... Pity, that.