Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1310650pxj; Fri, 4 Jun 2021 10:59:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyM+otHe5DW7PxK6wsiFV5OSP6kmV1ymF6VecOwVa1wqqXLJXDKvjBNQb7Djc66PJetYCHL X-Received: by 2002:a17:906:2c1b:: with SMTP id e27mr5407262ejh.5.1622829594650; Fri, 04 Jun 2021 10:59:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622829594; cv=none; d=google.com; s=arc-20160816; b=fxTwyxfm3mb3QWjNaJuVjXyYMnPZQvivc+c2hAKqbbet6HD7YH8vkQq9bozBsnw01q nO1i/n1QBlCOAur6eT54FCtH6pG4eilMMqS0oHw4dP0B59REiVJN0f2OLDq7HdAOEpcB JHtJdUoIxn3FG+tUHlD0M4afcMZ4bFE7p7eWciq3XkGVy8i6VDd9fNSDvPwHBPRiivc+ jj9Lfa2wZvLaxt5qet6nTMmbfqbwMny6l99aDHBA/2A7CulmiZaXbL79KpNswjTHt7J1 QD/t9QFr72ThRU7PQdnnYx7Usixl73qDyqLghmksOYlR/GjjBumxdfau/RzsbrxGXl+o EfAg== 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=32oaR0c8kPrg68WaYMsIVFX1pFixmYc8jBXuPce7aqw=; b=mSpEHPWiKLkMA6+ftrqXXuZyhKee7G8zimhgR1ab5kMOgE2i196zjMP9WDrS4lZCOY tdwUzPDTu9DBUq/jufuWNAFrxXevDfyhqEplmzdb1uknplbYOdoULgKc5OVRTW6YQwJs QfKFUJNi/+6S96xKO5/LRmX7yWY5eC7qsdMRj069Idxd2HwyfZt10QXCswtVVrkWAVgr 2jK52NsUmojzzgXizlXR8F32DmJobmnpQpOuLVrSUA4FuSZvIlaGAKohRQyqLfboGOYl tkyHCnvQ6avC7qes9z/w9PS1NlA98ZC8LUETDmmaomynbBPA9nMaaCOo2SV64gqNbolU XSlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=Arq+6pHA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hd11si4934083ejc.83.2021.06.04.10.59.30; Fri, 04 Jun 2021 10:59:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=Arq+6pHA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230185AbhFDR7v (ORCPT + 99 others); Fri, 4 Jun 2021 13:59:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229791AbhFDR7u (ORCPT ); Fri, 4 Jun 2021 13:59:50 -0400 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23688C061766 for ; Fri, 4 Jun 2021 10:58:04 -0700 (PDT) Received: by mail-lj1-x22b.google.com with SMTP id m3so12601687lji.12 for ; Fri, 04 Jun 2021 10:58:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=32oaR0c8kPrg68WaYMsIVFX1pFixmYc8jBXuPce7aqw=; b=Arq+6pHAhA+6mDmLufvN71tK/S4tPFoZ7Uq/geleo6of264AXrSe1tM+jluIf6B3zD AZs04X7ognuE3D2i6F0z9Mn1WqV2++xQDUMwY+aX2S+LMCtP/R376LwUOogcVxNXEcYc GOz9C5WIEQi6729yXjMf3BW/0QywFdq2zH07k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=32oaR0c8kPrg68WaYMsIVFX1pFixmYc8jBXuPce7aqw=; b=ecHVQ5VOymBj8mt/tFZq8puOt+TGs+VljBX39/3an675XAfThjPwFmftzVGMJwotJ3 CSFol3zWOv/7Osws8UVjGCtxpDWpUvhydOB07jVy82Y7jtqBxED7DBnPTbaNTTIv6hUF 3H4hEcUR8Qs66005RCDkE28a726Nt8VrUs6AlCdES4R1RaBbpqSz5L5YpG9SLoI5UqnP oLpXsIY1jQTf5NEJXBDDKdQHrb5spu2BNtQjFdpR0zR9rtIh2vLT40G9vtaBX1WfxNS5 g/xJsKddANyhRYN9xz6TlpYq5uM45fZ2tZES+d+s0g7X3U5LlXGkd5CYPWWS5upXp5vu G+YA== X-Gm-Message-State: AOAM532QWShgOTdQxrnvyFV5YJOzXVDb632w40G5Xogq/BBrAvyQqXQy hy1ZXtuBByruVil/TI7AFR2dHY+i7EZ5a+SMBfE= X-Received: by 2002:a2e:b0f5:: with SMTP id h21mr3707408ljl.325.1622829482305; Fri, 04 Jun 2021 10:58:02 -0700 (PDT) Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com. [209.85.208.169]) by smtp.gmail.com with ESMTPSA id z13sm774894lji.115.2021.06.04.10.58.00 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jun 2021 10:58:00 -0700 (PDT) Received: by mail-lj1-f169.google.com with SMTP id a4so12661129ljd.5 for ; Fri, 04 Jun 2021 10:58:00 -0700 (PDT) X-Received: by 2002:a2e:9644:: with SMTP id z4mr4336857ljh.507.1622829479784; Fri, 04 Jun 2021 10:57:59 -0700 (PDT) MIME-Version: 1.0 References: <20210525031636.GB7744@xsang-OptiPlex-9020> <20210604070411.GA8221@shbuild999.sh.intel.com> <20210604075220.GA40621@shbuild999.sh.intel.com> In-Reply-To: <20210604075220.GA40621@shbuild999.sh.intel.com> From: Linus Torvalds Date: Fri, 4 Jun 2021 10:57:44 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [mm/gup] 57efa1fe59: will-it-scale.per_thread_ops -9.2% regression To: Feng Tang Cc: Jason Gunthorpe , kernel test robot , John Hubbard , Jan Kara , Peter Xu , Andrea Arcangeli , "Aneesh Kumar K.V" , Christoph Hellwig , Hugh Dickins , Jann Horn , Kirill Shutemov , Kirill Tkhai , Leon Romanovsky , Michal Hocko , Oleg Nesterov , Andrew Morton , LKML , lkp@lists.01.org, kernel test robot , "Huang, Ying" , zhengjun.xing@intel.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 4, 2021 at 12:52 AM Feng Tang wrote: > > On Fri, Jun 04, 2021 at 03:04:11PM +0800, Feng Tang wrote: > > > > > > The perf data doesn't even mention any of the GUP paths, and on the > > > pure fork path the biggest impact would be: > > > > > > (a) maybe "struct mm_struct" changed in size or had a different cache layout > > > > Yes, this seems to be the cause of the regression. > > > > The test case is many thread are doing map/unmap at the same time, > > so the process's rw_semaphore 'mmap_lock' is highly contended. > > > > Before the patch (with 0day's kconfig), the mmap_lock is separated > > into 2 cachelines, the 'count' is in one line, and the other members > > sit in the next line, so it luckily avoid some cache bouncing. After > > the patch, the 'mmap_lock' is pushed into one cacheline, which may > > cause the regression. Ok, thanks for following up on this. > We've tried some patch, which can restore the regerssion. As the > newly added member 'write_protect_seq' is 4 bytes long, and putting > it into an existing 4 bytes long hole can restore the regeression, > while not affecting most of other member's alignment. Please review > the following patch, thanks! The patch looks fine to me. At the same time, I do wonder if maybe it would be worth exploring if it's a good idea to perhaps move the 'mmap_sem' thing instead. Or at least add a big comment. It's not clear to me exactly _which_ other fields are the ones that are so hot that the contention on mmap_sem then causes even more cacheline bouncing. For example, is it either (a) we *want* the mmap_sem to be in the first 128-byte region, because then when we get the mmap_sem, the other fields in that same cacheline are hot OR (b) we do *not* want mmap_sem to be in the *second* 128-byte region, because there is something *else* in that region that is touched independently of mmap_sem that is very very hot and now you get even more bouncing? but I can't tell which one it is. It would be great to have a comment in the code - and in the commit message - about exactly which fields are the criticial ones. Because I doubt it is 'write_protect_seq' itself that matters at all. If it's "mmap_sem should be close to other commonly used fields", maybe we should just move mmap_sem upwards in the structure? Linus