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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35AE4C6FA8E for ; Wed, 21 Sep 2022 01:51:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AED8E8000A; Tue, 20 Sep 2022 21:51:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A9C1C80009; Tue, 20 Sep 2022 21:51:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 964218000A; Tue, 20 Sep 2022 21:51:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 87D9180009 for ; Tue, 20 Sep 2022 21:51:43 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 5939EC0EB4 for ; Wed, 21 Sep 2022 01:51:43 +0000 (UTC) X-FDA: 79934416086.04.36AB1AE Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) by imf06.hostedemail.com (Postfix) with ESMTP id F245018001B for ; Wed, 21 Sep 2022 01:51:42 +0000 (UTC) Received: by mail-ed1-f43.google.com with SMTP id f20so6480662edf.6 for ; Tue, 20 Sep 2022 18:51:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=exktuqp3Yz0O7DTOQAZcnS95GYeriR3HpkAUKtRfC9k=; b=prR2d7IC8d3KTQfnrJuC6umcuUbOTsTHYnt/TN+mB7C0ksEVF09+y5pzwSr5hUcgfQ 3S6TNC1vUWzt0CWTWTgxvQjIa+srt85URQX7boT8YzDwD04EMRwBIQ5wnmBXQh5ojZFP mb5cXtroEJ1QUj5aQRtcZ2eSbRkZJBKgrfwSP3a1AOX3PzhiPJyWAxUHhPNM+zljeEdC RPEj/BOnWcjjlJYt0fOi284UWlelcdxkXKEvCjZSCzcEsRYi4gcGLSaSfe1/qg6igU91 8UMCYOG2BCz3q0FrpJnwDfEEW2sdvH6TIn+LqzqIaLzJkw4LJ5e/RUB96Vy1z5+wyzxa 40yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=exktuqp3Yz0O7DTOQAZcnS95GYeriR3HpkAUKtRfC9k=; b=SeXMzk0jYAe07ol8FOFiVYOdok9yniXoWZEY8gIGt7TddALDRljZbUTP8Rb/NcjWJe zUKUSvDNnWBpaZdM29l0XagMwYiIxrbP67DPnTYRqpVQaklTOFaE1pCzQqbp5F0ktyHf nxgJDxal46YidUc2Av1wF1aOF5hnqZy3cZuOcnUOoyPV2M28Em4MIPvr40eh8r3o1lFv kB6yeI5goF35MqgS5zDqM14+55TrMT4cG3Ugb4gkOcEI43ketD8l/m2lZ5rvOXs6sFA/ FjdB37hxn8jBBzU15QXtkvwSjJGKF5kfMNRADse0k4VQs88QU0eqd/LgD7OkTNhoug23 aUzw== X-Gm-Message-State: ACrzQf2O26w2Cu1K4tragM0MEz8YXwAeWH90LBoSvFdnZRireSYVO/7W 2QKE+/GcmIMhpo8L43T/mxfaWj95ZBMVqv3C8hA= X-Google-Smtp-Source: AMsMyM5v9dTlzaqMHbzByB0iQp6q4d17pnEGAvmmK5ZnmNrYfXTWs2nOXnV+B27bLIMXIY5zqA4ppXvLi5hsTQlRwTY= X-Received: by 2002:a05:6402:184:b0:442:fd54:2a21 with SMTP id r4-20020a056402018400b00442fd542a21mr22357803edv.129.1663725101717; Tue, 20 Sep 2022 18:51:41 -0700 (PDT) MIME-Version: 1.0 References: <20220822082120.8347-1-yangyicong@huawei.com> <20220822082120.8347-5-yangyicong@huawei.com> <302febae-508c-d73e-8676-d51752946645@arm.com> <8c4f103b-8f04-d0ad-b30a-2db7e52b36a3@arm.com> In-Reply-To: From: Barry Song <21cnbao@gmail.com> Date: Wed, 21 Sep 2022 13:51:30 +1200 Message-ID: Subject: Re: [PATCH v3 4/4] arm64: support batched/deferred tlb shootdown during page reclamation To: Anshuman Khandual Cc: Yicong Yang , 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, corbet@lwn.net, peterz@infradead.org, 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, linux-mips@vger.kernel.org, openrisc@lists.librecores.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, wangkefeng.wang@huawei.com, xhao@linux.alibaba.com, prime.zeng@hisilicon.com, Barry Song , Nadav Amit , Mel Gorman Content-Type: text/plain; charset="UTF-8" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663725103; a=rsa-sha256; cv=none; b=Bkt+aSZzPRsqT/yEMCQLksJUwwqyJLx+/36US3RzN2vyZ2EOPfifzkC3Se2s+MlGuAdKd5 nB2iCfcYgnAdb8bkyt0tOrA34QmrmVlhpwH0VsjUPEj7F/5jw0vQ/8b99U0OalesmLKeKS FslUSWo9QnlMlog20ybgY/FMA5Gu6kM= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=prR2d7IC; spf=pass (imf06.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.208.43 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663725102; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=exktuqp3Yz0O7DTOQAZcnS95GYeriR3HpkAUKtRfC9k=; b=3ppc0D+ba1+VxtKfCNRx/xVi5CE1WUm/02bTdZIGmP8PrlLQu8vTPwaNnvXzANuZtPYVJR rBEtNPASjP7MNHP7kjbLtcNrBsKLeATgiGJ71cznWX2A27FHUg06DRML5lQkSUYUzZEGlv mTMRhus+XluVat2l1DilnyIzSSPkzVg= X-Rspamd-Queue-Id: F245018001B X-Rspam-User: Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=prR2d7IC; spf=pass (imf06.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.208.43 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam11 X-Stat-Signature: a87qis499gn9khaxac4kdphxkc5ycn7c X-HE-Tag: 1663725102-27843 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: On Wed, Sep 21, 2022 at 1:50 PM Barry Song <21cnbao@gmail.com> wrote: > > On Tue, Sep 20, 2022 at 8:45 PM Anshuman Khandual > wrote: > > > > > > > > On 9/20/22 09:09, Barry Song wrote: > > > On Tue, Sep 20, 2022 at 3:00 PM Anshuman Khandual > > > wrote: > > >> > > >> > > >> On 8/22/22 13:51, Yicong Yang wrote: > > >>> +static inline bool arch_tlbbatch_should_defer(struct mm_struct *mm) > > >>> +{ > > >>> + return true; > > >>> +} > > >> > > >> This needs to be conditional on systems, where there will be performance > > >> improvements, and should not just be enabled all the time on all systems. > > >> num_online_cpus() > X, which does not hold any cpu hotplug lock would be > > >> a good metric ? > > > > > > for a small system, i don't see how this patch will help, e.g. cpus <= 4; > > > so we can actually disable tlb-batch on small systems. > > > > Do not subscribe ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH based on NR_CPUS ? > > That might not help much as the default value is 256 for NR_CPUS. > > > > OR > > > > arch_tlbbatch_should_defer() checks on > > > > 1. online cpus (dont enable batched TLB if <= X) > > 2. ARM64_WORKAROUND_REPEAT_TLBI (dont enable batched TLB) > > > > > just need to check if we will have any race condition since hotplug will > > > make the condition true and false dynamically. > > > > If should_defer_flush() evaluate to be false, then ptep_clear_flush() > > clears and flushes the entry right away. This should not race with other > > queued up TLBI requests, which will be flushed separately. Wondering how > > there can be a race here ! > > Right. How about we make something as below? > > static inline bool arch_tlbbatch_should_defer(struct mm_struct *mm) > { > /* for a small system very small number of CPUs, TLB shootdown is cheap */ > if (num_online_cpus() <= 4 || > unlikely(this_cpu_has_cap(ARM64_WORKAROUND_REPEAT_TLBI))) > return false; > > #ifdef CONFIG_ARM64_WORKAROUND_REPEAT_TLBI > if (unlikely(this_cpu_has_cap(ARM64_WORKAROUND_REPEAT_TLBI))) > return false; > #endif > > return true; > } sorry, i mean static inline bool arch_tlbbatch_should_defer(struct mm_struct *mm) { /* for a small system very small number of CPUs, TLB shootdown is cheap */ if (num_online_cpus() <= 4) return false; #ifdef CONFIG_ARM64_WORKAROUND_REPEAT_TLBI if (unlikely(this_cpu_has_cap(ARM64_WORKAROUND_REPEAT_TLBI))) return false; #endif return true; } > > Thanks > Barry