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 AB97BC6FA82 for ; Tue, 20 Sep 2022 08:45:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1F24F940008; Tue, 20 Sep 2022 04:45:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A1BB940007; Tue, 20 Sep 2022 04:45:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 091B5940008; Tue, 20 Sep 2022 04:45:50 -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 EF350940007 for ; Tue, 20 Sep 2022 04:45:49 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C16B21A1CE7 for ; Tue, 20 Sep 2022 08:45:49 +0000 (UTC) X-FDA: 79931830818.22.4F12719 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf23.hostedemail.com (Postfix) with ESMTP id 2C402140012 for ; Tue, 20 Sep 2022 08:45:49 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6ED20106F; Tue, 20 Sep 2022 01:45:54 -0700 (PDT) Received: from [10.163.57.146] (unknown [10.163.57.146]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EE8EE3F73B; Tue, 20 Sep 2022 01:45:37 -0700 (PDT) Message-ID: <8c4f103b-8f04-d0ad-b30a-2db7e52b36a3@arm.com> Date: Tue, 20 Sep 2022 14:15:34 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v3 4/4] arm64: support batched/deferred tlb shootdown during page reclamation Content-Language: en-US To: Barry Song <21cnbao@gmail.com> 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 References: <20220822082120.8347-1-yangyicong@huawei.com> <20220822082120.8347-5-yangyicong@huawei.com> <302febae-508c-d73e-8676-d51752946645@arm.com> From: Anshuman Khandual In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663663549; a=rsa-sha256; cv=none; b=twh559XbaSIrhs9AlPbNrkuqWEXd7Iky2QXwGl2wft3kSkE5+YwiWudH4aZP8p9fwnaCOP SLQqtNFEL/tF+HOecLqQyHwo/G1QzKqMLA1t2UTI/+uT2bcvqqiPHXYC0uYNq4hWPviaLE Z6ZdnxsK6y3n4PhYBnaQPJbCn0SvdvY= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663663549; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lVGUVwVq+mMnima89Ad9m5xcF2LFlOj6X02G84RYxao=; b=S8kf0PxCWn1fA++sXD8FLZMr4F7NtzgUNnmpqwI6mfD5JdrpTuzWFe4Vf5UKI3q4NrrxoR WpzFcMBxkucxAz9VgH8O+jpeiUYoidvV5GcId+beKNQVKprBe+elh/i9cC7mbJYInqySiB 6DjjAXpnpwUlpPwjr8q6PFh7q3i1Ijo= X-Stat-Signature: h9x8ajeofhsf4pbh55n67pfjuwmze4qb X-Rspamd-Queue-Id: 2C402140012 Authentication-Results: imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com; dmarc=pass (policy=none) header.from=arm.com X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1663663549-45623 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 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 !