From patchwork Thu Jul 7 12:52:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Barry Song <21cnbao@gmail.com> X-Patchwork-Id: 12909535 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E798C433EF for ; Thu, 7 Jul 2022 12:53:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9F7A96B0074; Thu, 7 Jul 2022 08:53:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9A6886B0075; Thu, 7 Jul 2022 08:53:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 86E7A6B0078; Thu, 7 Jul 2022 08:53:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 788126B0074 for ; Thu, 7 Jul 2022 08:53:19 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 4C12F80E1B for ; Thu, 7 Jul 2022 12:53:19 +0000 (UTC) X-FDA: 79660294518.05.F17D9DE Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by imf01.hostedemail.com (Postfix) with ESMTP id E0DEA40010 for ; Thu, 7 Jul 2022 12:53:18 +0000 (UTC) Received: by mail-pf1-f179.google.com with SMTP id a15so19147568pfv.13 for ; Thu, 07 Jul 2022 05:53:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KohxSBlyb2gPjZjQOuscJE9srXX9sKJcN9WDxnjJeNE=; b=Z/4G+j0uofz5mjT+m2wBBS33jHt4uCc2grw6vajzycA8dAivB2I1E1uYK99jJIfo3O +QVMHgjhpLcxM5rK9KyJLhGd/2RG7WG+m+aIuZ3X5Dg4EPoe2WAdSN9T1oNWhnIRZCdt ZtoFweBV2b0oTa0dw6ht0oMasl/SwPv6uthPPSyM3N0RJ0saHZLDz4W90bArUtgevKYX m4cfQNFxf1WMKIGk+78eEF2P//QSs/IM5W/9lyROXPgyN8uTHDD7SQNwWbsVEYeSgcNq xvvHmPTuceHpBwtGmhSs2cQ4RtAGjDNqkq+j6cmwe55l10OUsxpR+oO0AVJ7Iz/bxSVX mLOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KohxSBlyb2gPjZjQOuscJE9srXX9sKJcN9WDxnjJeNE=; b=sBTdpiW6X2cw93yHOWJ+8V/RWBP2NfGaTP5REaQaJ9q2FXQYv1UqUQDcNLD7dmuhtl Nhgm95JQfUJ7ruv2edxu8Aj4Sm+JfCbVXbFYGE2gjAMFjuBlbILxz7xAnUOK/PIu04E2 EOuV21VjmZEE+3DHFEC6Jlbx5sVYcQJ3sInWjwGRCImS5C173hTEy50y/+B8lFdDMy/y LdbGrSjHEdO6wKhk9MHxyUyQvNGmYtsajztmyfzntEfs+af3k8xZz8vCE1l9eGXN1FOE 70QWU8VCv0rZW+8cTa1gLwQZzkwyq5igf8t13wS2gkDJ9Z0KL6QInPn06PNu/SDOxdT+ 3H2A== X-Gm-Message-State: AJIora9wfszpy80gL4+KvWlCySHzsq2v0oPZx9yfUgMaNZExQzg3uD4A psX+PBpfztKqGmu/6JAu7MrG84K4jFRkLg== X-Google-Smtp-Source: AGRyM1tvGgyyQudlC4LStAUoiLkQLMqA8RlR3btbebQT65iLnPCQfEEP4u4looKoNOsGSkmoEtUiHg== X-Received: by 2002:a17:902:e809:b0:16a:22dc:d23a with SMTP id u9-20020a170902e80900b0016a22dcd23amr53568912plg.119.1657198397970; Thu, 07 Jul 2022 05:53:17 -0700 (PDT) Received: from localhost.localdomain (47-72-206-164.dsl.dyn.ihug.co.nz. [47.72.206.164]) by smtp.gmail.com with ESMTPSA id a11-20020a1709027e4b00b0016a3b5a46f0sm27907831pln.241.2022.07.07.05.53.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 05:53:17 -0700 (PDT) From: Barry Song <21cnbao@gmail.com> To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, catalin.marinas@arm.com, will@kernel.org, linux-doc@vger.kernel.org Cc: corbet@lwn.net, arnd@arndb.de, linux-kernel@vger.kernel.org, darren@os.amperecomputing.com, yangyicong@hisilicon.com, huzhanyuan@oppo.com, lipeifeng@oppo.com, zhangshiming@oppo.com, guojian@oppo.com, realmz6@gmail.com, Barry Song , Nadav Amit , Mel Gorman Subject: [PATCH 2/4] mm: rmap: Allow platforms without mm_cpumask to defer TLB flush Date: Fri, 8 Jul 2022 00:52:40 +1200 Message-Id: <20220707125242.425242-3-21cnbao@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220707125242.425242-1-21cnbao@gmail.com> References: <20220707125242.425242-1-21cnbao@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657198399; a=rsa-sha256; cv=none; b=RZ2AKuL2BbaMvSVKwxcdmq9Cysua7cDGR4LxTEGsfnICsJxYL/eqstKn++kv0+pHcrh7zN /53LdXYcW4+P1K4Iyviwh0fw76JREk3tvUqY6w88njpzrAHuiI6Fpy/7yggAFJ2ymMiVj2 l+8rSr7x1YqzdA6L8gBwM1mRkxiNvbM= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="Z/4G+j0u"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.210.179 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657198399; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=KohxSBlyb2gPjZjQOuscJE9srXX9sKJcN9WDxnjJeNE=; b=HrEWxrNw06fauB2Ruf21BSM5I5pDfqI+k6VwSngT68qHxeQezLMM82wUnTh0GBPhlbQCk+ jEF4GGW2AWemJmvxASg6xxzB9QNZehycKSwlc9VKGNnY5vTUYg4EfXTByP6+3UReQMunQr cxaFyAWOAE8XuUlqazFZrkbd7mV5F+U= X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: E0DEA40010 X-Rspam-User: Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="Z/4G+j0u"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.210.179 as permitted sender) smtp.mailfrom=21cnbao@gmail.com X-Stat-Signature: dp8xoh68w87hre3663rtep3za3nstddg X-HE-Tag: 1657198398-583897 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Barry Song Platforms like ARM64 have hareware TLB shootdown broadcast. They don't maintain mm_cpumask and they just send tlbi and related sync instructions for TLB flush. So if mm_cpumask is empty, we also allow deferred TLB flush Cc: Nadav Amit Cc: Mel Gorman Signed-off-by: Barry Song > --- mm/rmap.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mm/rmap.c b/mm/rmap.c index 5bcb334cd6f2..d320c29a4ad8 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -692,8 +692,13 @@ static bool should_defer_flush(struct mm_struct *mm, enum ttu_flags flags) if (!(flags & TTU_BATCH_FLUSH)) return false; - /* If remote CPUs need to be flushed then defer batch the flush */ - if (cpumask_any_but(mm_cpumask(mm), get_cpu()) < nr_cpu_ids) + /* + * If remote CPUs need to be flushed then defer batch the flush; + * If ARCHs like ARM64 have hardware TLB flush broadcast, thus + * they don't maintain mm_cpumask() at all, defer batch as well. + */ + if (cpumask_any_but(mm_cpumask(mm), get_cpu()) < nr_cpu_ids || + cpumask_empty(mm_cpumask(mm))) should_defer = true; put_cpu();