Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp2795771rdb; Wed, 15 Nov 2023 10:39:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IGOY6inFslUfuHAhWfmvNbqsu4bSL8jrj2HT2dDYAvof3v+IPu+laY7pH3v5YNGWNVDg3Fo X-Received: by 2002:a9d:4e98:0:b0:6cd:4ff:e1eb with SMTP id v24-20020a9d4e98000000b006cd04ffe1ebmr6795514otk.20.1700073545561; Wed, 15 Nov 2023 10:39:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700073545; cv=none; d=google.com; s=arc-20160816; b=Vy8xT6KXO9XHEdFfEEEq8p/acQn/9kupD9NByMqOm0/WFDNngh6UgpBeEMqcBLTTXW s8TnT1ufSmdyEmQ9de333tCWaPFljwkdNy+3lWm4qKi/MMLDeUDNSiVCx2HkysmmEu9H ItoBma8RYyAQ3aTPSBTHn8eS8p7y3qmSl+30C50qt6422asIuFY9bLpK2pXQp6HJhFhr wPFu0NOA+leVBv3BeGCDRGjiMqq9RJxEwRzv2ihHkUTx+/NJdGI34JhE21+pJQj4ZsLA xy4O1TAoGygHCV2tSuzPYTI/mZHadnqoBHTYFvIvXSab68f3bWjmFluDw37NN9qvXGmI /GuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=0MD0pshjJBw/chdZXVFrwHJqdy9ZbUZCE/cfITJ+qfg=; fh=RrAam1Vokkh86vfKINZgBfaA0wCh4yqlkUrKr9+6yac=; b=cRAqQUkjCfMyM4dugk11uDtI7BdcQZNbviw9adsAsJJyXxmNLbXokBb27FCMUbehXH HjN9KInnqSlz84kbh0yKb/Xgv3YEq0QTZjmEWDWnRBAGgHqdFrBjv3PqUvQUxnRieI9j ex/SfCCbqwzUowNz5FSEb1aADwpUd+dEnHsCoI/WZ4KVK3tLFG4qjEYdYVGtxUqVuQoN jkmavVRmnVx5662ew6qjqUt7PlPpv9SHoQ7NJmTtpaEU93t2y+FG2eb3xIzCuKg9wFmA pyPQn7R1SRZquyfvQbG7ee4YY304WzDte0MN/VyIc+a3BVkNcebTUWWvVHwXYyuB1+co lcYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=DuOVREJK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id h63-20020a638342000000b005c158d87581si2227098pge.659.2023.11.15.10.39.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 10:39:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=DuOVREJK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id A351C80A18E1; Wed, 15 Nov 2023 10:39:02 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229561AbjKOSin (ORCPT + 99 others); Wed, 15 Nov 2023 13:38:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229492AbjKOSim (ORCPT ); Wed, 15 Nov 2023 13:38:42 -0500 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D0DCAF for ; Wed, 15 Nov 2023 10:38:39 -0800 (PST) Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-53db360294fso11053108a12.3 for ; Wed, 15 Nov 2023 10:38:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1700073517; x=1700678317; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=0MD0pshjJBw/chdZXVFrwHJqdy9ZbUZCE/cfITJ+qfg=; b=DuOVREJKZ4MBzamPIlxdZ1MDp3bE5vLc3eQaJi+51W4f4OCyLiL4Za8kAwfn83ZMcI +cRAapwnDaAlpMr0pWW6FJwVyd8wocYuh4mm2frubNm4wpKC/rfbYoNu4+nmnGgGSAEU Ng0EdHUC7Fzo4FMMrXXVK8c7HziRZgFavHKJE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700073517; x=1700678317; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0MD0pshjJBw/chdZXVFrwHJqdy9ZbUZCE/cfITJ+qfg=; b=C22iKyEGRfAKxqvxhYwmsPGpoSbjmX6MsaPBpfHl8aAW9jGguo65/GfarnU29gNixk rCK7Jx6YGEUZ/xe7J93Qd6xw6+0vbITs/nlyEHaPwnNb4HozfWadyTsSxM4iLaBIuK3+ IxzwHvp9PQcKobpppurHS3qVz/OB84mo566W+g9379BxfbVhc1l+nFLy5fZZlFvBK4IS 0vqftpZkE6l+McVrtvKx3M1ruPRXfNbKsPaj/mxZymT2NXZYO3kTWdRQwepWgXnrZoPe w8ueO/oPpm1/KoOSoeSYKgGTqpZPy5+um9WTMN5/gAw0biWfVbJkfhS3tCzV/ff93tGB EgcA== X-Gm-Message-State: AOJu0Yz9aYhPzlYe9B31/qyTGyC8LZMQ4tkH3X7ItfS4elAsnYci4d86 p8N8GCMvpuMIEgn7g59n1QT7fEGpZyf9BWGCFHlCJcPh X-Received: by 2002:a17:906:c787:b0:9ad:be8a:a588 with SMTP id cw7-20020a170906c78700b009adbe8aa588mr9690101ejb.1.1700073517353; Wed, 15 Nov 2023 10:38:37 -0800 (PST) Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com. [209.85.208.47]) by smtp.gmail.com with ESMTPSA id l22-20020a170906a41600b0099d798a6bb5sm7416670ejz.67.2023.11.15.10.38.36 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Nov 2023 10:38:36 -0800 (PST) Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-53df747cfe5so11043661a12.2 for ; Wed, 15 Nov 2023 10:38:36 -0800 (PST) X-Received: by 2002:a05:6402:11c8:b0:543:c578:f9d2 with SMTP id j8-20020a05640211c800b00543c578f9d2mr14437856edw.2.1700073516118; Wed, 15 Nov 2023 10:38:36 -0800 (PST) MIME-Version: 1.0 References: <202311061616.cd495695-oliver.sang@intel.com> <3865842.1700061614@warthog.procyon.org.uk> In-Reply-To: From: Linus Torvalds Date: Wed, 15 Nov 2023 13:38:18 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [linus:master] [iov_iter] c9eec08bac: vm-scalability.throughput -16.9% regression To: David Howells , Borislav Petkov Cc: kernel test robot , oe-lkp@lists.linux.dev, lkp@intel.com, linux-kernel@vger.kernel.org, Christian Brauner , Alexander Viro , Jens Axboe , Christoph Hellwig , Christian Brauner , Matthew Wilcox , David Laight , ying.huang@intel.com, feng.tang@intel.com, fengwei.yin@intel.com Content-Type: multipart/mixed; boundary="000000000000059111060a3536ba" X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 15 Nov 2023 10:39:02 -0800 (PST) --000000000000059111060a3536ba Content-Type: text/plain; charset="UTF-8" On Wed, 15 Nov 2023 at 12:38, Linus Torvalds wrote: > > The gcc code generation here is *really* odd. I've never seen this > before, so it may be new to newer versions of gcc. [...] Ok, so I've been annoyed by gcc code generation for 'memcpy()' before, mainly because it can't do the "let's inline it as an ALTERNATIVE() of 'rep movs' or an out-of-line call" thing that we do for user copies. So here's a complete hack that says "we override the __builtin_memcpy() implementation for non-constant lengths". We stillwant gcc to deal with the constant size case, since often that can be turned into just plain moves. And this is *ENTIRELY* untested, except for checking that it makes the code generation in lib/iov_iter.c look better. It's probably completely broken. I particularly worry about "memcpy()" being used *during* the instruction rewriting, so the whole approach with ALTERNATIVE() is probably entirely broken. But I'm cc'ing Borislav, because we've talked about the whole "inline memcpy() with alternatives" before, so maybe this gives Borislav some ideas for how to do it right. Borislav, see https://lore.kernel.org/all/CAHk-=wjCUckvZUQf7gqp2ziJUWxVpikM_6srFdbcNdBJTxExRg@mail.gmail.com/ for some truly crazy code generation by gcc. Linus --000000000000059111060a3536ba Content-Type: text/x-patch; charset="US-ASCII"; name="patch.diff" Content-Disposition: attachment; filename="patch.diff" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_lp03tds80 IGFyY2gveDg2L2luY2x1ZGUvYXNtL3N0cmluZ182NC5oIHwgMjIgKysrKysrKysrKysrKysrKysr KysrKwogaW5jbHVkZS9saW51eC9mb3J0aWZ5LXN0cmluZy5oICAgfCAgMSArCiAyIGZpbGVzIGNo YW5nZWQsIDIzIGluc2VydGlvbnMoKykKCmRpZmYgLS1naXQgYS9hcm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