Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp605783pxa; Wed, 19 Aug 2020 09:52:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwn1YkfRllQzQyYQRc6FCx2DwSfx4EQLo+SbKR3mN9xexYlp+maaOwxi0LJJbTOAuj5WfEU X-Received: by 2002:a50:935a:: with SMTP id n26mr25771843eda.107.1597855963351; Wed, 19 Aug 2020 09:52:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597855963; cv=none; d=google.com; s=arc-20160816; b=BJ9Dfv6RcAeyqMR0/V4hDguuDVSCQg6BPxVjMb0TP5a+eLpzuDdcDzuWTVHL9jueb4 X5/Xyl3QeACHeSGaAWm/5KBZR3D/3IiyZYKZe5rRqS0VZ39RTBoS8SDxjXzzBudsRqun 9kuLAgBLFUTagWaN4FbWw5nYlO29kaqa6itgjtzfK8kHT5FkPEg4kAIWXjuF82hqhSuA jtj5HHucbT2wXpvX/Zvounbx4uZ+KmSy6aK+FgRCXksbVIusL/3pgL/U5mK4itNJu6/+ 3VZM2hRvsMYU9LSCwMTJsNZIUSfwX4dbZ0xdGXQgivSIlLCoB8KUMFFs9YB6B13lbd9y tmsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=5MrhWijunOxFmEpPBfxi3nnE6h7nM/ESqf0MycrK1bc=; b=wU/rsm0uvUNFbp6yR8/LPOpLCXrOcTse8pl5RrcPB0vEyaQeNkL7Dr5CvzYgiATpdT btSsTzL0M5krw/50pS3oLsnzxeOOaER0i7zHuiyXSfHH37ZEfHIcCpOoNaKo2EjRn+wy CJ2bxUmof8qd1P9MYAIECj1pAoNeQJsmOen97sgrbv3bXwj/ZzXa6cg4Uh73iOdkjD0k dmbhAX08u1luR2bfyQAOsedYb0OMKIIlDxOaH0hl4ENaGCmBqrbU0Zh5vWN9KqrGrZPp aDb6NKwWJo17qY5GBAF3UfZdPPk3NwDTH315tbowSABRbAmv+/YXvwnHpVfVjoffxIxe E+0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=W9P7Q8MB; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e12si15803070edn.431.2020.08.19.09.52.17; Wed, 19 Aug 2020 09:52:43 -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=@gmail.com header.s=20161025 header.b=W9P7Q8MB; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726703AbgHSQu4 (ORCPT + 99 others); Wed, 19 Aug 2020 12:50:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726414AbgHSQuy (ORCPT ); Wed, 19 Aug 2020 12:50:54 -0400 Received: from mail-il1-x144.google.com (mail-il1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF8A0C061757 for ; Wed, 19 Aug 2020 09:50:54 -0700 (PDT) Received: by mail-il1-x144.google.com with SMTP id e11so13284388ils.10 for ; Wed, 19 Aug 2020 09:50:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=5MrhWijunOxFmEpPBfxi3nnE6h7nM/ESqf0MycrK1bc=; b=W9P7Q8MBYzAc+VHyoKcnaxdruKcc9ZSyiScd2J9v6cmWw9V53iCYL9xm13GYojtTkR O6m5ZuZ9sEndatn2ReAANkq9jfawHew8GkHaxJ7eCnNbboi2Rrr2dEhAGzjGMmiU0eoT Z8cmT1nhszZ5Ckk1v697ZJR/Q+V4CZtXY3FE3dU+Z7xU5ZX8wl9HYV/a6xtCQYb4uP5P mnIleeiKLLzpUzagPV4LUSGt3TjxNf950c8/KRfjdkpt8dxuVU9b+dxFWW9IRB3oVPjc EYqkKspt3S6ncXjxD8QGNeqVZ1flPjVKbPN35R7csKRwUoZQ6YrDEP4I5Q/DzmPV//qt zAJA== 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:content-transfer-encoding; bh=5MrhWijunOxFmEpPBfxi3nnE6h7nM/ESqf0MycrK1bc=; b=TdbtXiM+yE1YNeAVzaX5LRs+LXEoBgsTq+GfOVm45KpIoCxb5NsnsFJaKD3g6EBhH0 wA08eHfXnNL9qKbZlXL00c9BBNH44V/1+W/xx0Ss0ovFyHX7tCtsXKYEWHyyVBrAfHP6 IdM1hClhlKcwpCmL7JmxssbJ3dII30aGz+yOqfCQMevBsY3bPwqhYu9FAFAaTWD1aFKt nDX1VRiRwo0Np04/t1e5ECKFiVaSE9Tu+msKhl2Jj9b8phcO8uou408wRrQBLOfPGnP1 Fu4RyehHayMZozWohQu0kphTSMK2FW09cofQOt90/t8peO1HSETIqmvQ5iB4b+4uGXRz fetw== X-Gm-Message-State: AOAM530IBPmNzOCRX2LspzFriWttzy9VIxIsN5ijEEJn7Po1Ciz8h46X kOneUuV8HzunWlrgJEmsFkcYR15VEvhA3yLtEzg= X-Received: by 2002:a92:c8c1:: with SMTP id c1mr23266694ilq.42.1597855853425; Wed, 19 Aug 2020 09:50:53 -0700 (PDT) MIME-Version: 1.0 References: <1597816075-61091-1-git-send-email-alex.shi@linux.alibaba.com> <1597816075-61091-2-git-send-email-alex.shi@linux.alibaba.com> <715f1588-9cd5-b845-51a5-ca58549c4d28@arm.com> In-Reply-To: From: Alexander Duyck Date: Wed, 19 Aug 2020 09:50:42 -0700 Message-ID: Subject: Re: [PATCH v2 2/2] mm/pageblock: remove false sharing in pageblock_flags To: Alex Shi Cc: Anshuman Khandual , Matthew Wilcox , David Hildenbrand , Andrew Morton , Hugh Dickins , Alexander Duyck , LKML , linux-mm Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 19, 2020 at 1:11 AM Alex Shi wrote= : > > > > =E5=9C=A8 2020/8/19 =E4=B8=8B=E5=8D=883:57, Anshuman Khandual =E5=86=99= =E9=81=93: > > > > > > On 08/19/2020 11:17 AM, Alex Shi wrote: > >> Current pageblock_flags is only 4 bits, so it has to share a char size > >> in cmpxchg when get set, the false sharing cause perf drop. > >> > >> If we incrase the bits up to 8, false sharing would gone in cmpxchg. a= nd > >> the only cost is half char per pageblock, which is half char per 128MB > >> on x86, 4 chars in 1 GB. > > > > Agreed that increase in memory utilization is negligible here but does > > this really improve performance ? > > > > It's no doubt in theory. and it would had a bad impact according to > commit e380bebe4771548 mm, compaction: keep migration source private to = a single > > but I do have some problem in running thpscale/mmtest. I'd like to see if= anyone > could give a try. > > BTW, I naturally hate the false sharing even it's in theory. Anyone who d= oesn't? :) You keep bringing up false sharing but you don't fix the false sharing by doing this. You are still allowing the flags for multiple pageblocks per cacheline so you still have false sharing even after this. What I believe you are attempting to address is the fact that multiple pageblocks share a single long value and that long is being used with a cmpxchg so you end up with multiple threads potentially all banging on the same value and watching it change. However the field currently consists of only 4 bits, 3 of them for migratetype and 1 for the skip bit. In the case of the 3 bit portion a cmpxchg makes sense and is usually protected by the zone lock so you would only have one thread accessing it in most cases with the possible exception of a section that spans multiple zones. For the case such as the skip bit and MIGRATE_UNMOVABLE (0x0) where we would be clearing or setting the entire mask maybe it would make more sense to simply use an atomic_or or atomic_and depending on if you are setting or clearing the flag? It would allow you to avoid the spinning or having to read the word before performing the operation since you would just be directly applying an AND or OR via a mask value.