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 45A85C77B7A for ; Tue, 16 May 2023 12:09:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A47B0900007; Tue, 16 May 2023 08:09:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9F7D8900002; Tue, 16 May 2023 08:09:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8BF94900007; Tue, 16 May 2023 08:09:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7B83D900002 for ; Tue, 16 May 2023 08:09:38 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 42FB9A0250 for ; Tue, 16 May 2023 12:09:38 +0000 (UTC) X-FDA: 80795998836.01.9C1B43C Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf02.hostedemail.com (Postfix) with ESMTP id 2CC0080012 for ; Tue, 16 May 2023 12:09:34 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=F+R2Q6l3; dkim=pass header.d=linutronix.de header.s=2020e header.b=j+adUGTy; spf=pass (imf02.hostedemail.com: domain of tglx@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=tglx@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684238975; 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=0CQ+jS14zLcnozgvOt5eiAa5pnAfQVabet0JoqqqapU=; b=zHkACOPng73qTRlq/eXTLsExLWlrBRejrSgg7OcnAYnDXqS7+UFPSeXza50bVcyZBPk5TO mzCA4kP+K4NFDpf46ORHSP3SXiDdbzLPB5ojipXibB96cBR8ZEQ20DV//dip14ZXCXr//2 KlgGnWMxgdz+1uLBs9Ov1W+JrV42cXw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684238975; a=rsa-sha256; cv=none; b=PpchFt6PvfN6zGducliTnZImCJ1B6R88mEAw1kZaeweuPrfh9Jrvop/wRB/lT2mAb+tD7/ T5pgIJivg24Kep06Bpr/FN2efmwF1qn0GjvQBSKhdXa8PWX9UjkauzNUY6MDQViKbqRRvf D1h05odcoLnojUxF5Eq1N7MmOt0P/TQ= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=F+R2Q6l3; dkim=pass header.d=linutronix.de header.s=2020e header.b=j+adUGTy; spf=pass (imf02.hostedemail.com: domain of tglx@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=tglx@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1684238972; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0CQ+jS14zLcnozgvOt5eiAa5pnAfQVabet0JoqqqapU=; b=F+R2Q6l3OudIxAF2jpENc2N+1M/KC8Ts6Rt8UXgtKA/3XngNdjIfvLbntEgX9q7cB3tCwT WOUxSp5Ez4+d+Hk6mZBU92bor8JY4eKrbYFtbOlS6ndBuUL3CYrZek18mQxv0j1Bj98Rbj fvJKjXYnuUSFbGahhxQWc5l24KTpWLt2b++x3LqultAvytsoitub3nLCiOSp8oqgW22xsB RWq8BST/h+tFP1DqfwfjnDE5iS30P7Pu+Fk8cR5Gd/zwovnBhGrTUbXKGVfN9JnkdNn+7r gr9gnJ9fBJsWbLqHfIG1++RGzN47TvTJUDmG7rBS81ewEOusWBeR2VKyixj7RA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1684238972; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0CQ+jS14zLcnozgvOt5eiAa5pnAfQVabet0JoqqqapU=; b=j+adUGTyuvlY/Dec510Z92zNWQxc+nbL6bbqR+ZX5EwNTbLmocylleWbkLnaEoMyJJarnQ AoGjc6/qa5rLQBCg== To: "Russell King (Oracle)" Cc: Andrew Morton , linux-mm@kvack.org, Christoph Hellwig , Uladzislau Rezki , Lorenzo Stoakes , Peter Zijlstra , Baoquan He , John Ogness , linux-arm-kernel@lists.infradead.org, Mark Rutland , Marc Zyngier , x86@kernel.org Subject: Re: Excessive TLB flush ranges In-Reply-To: References: <87a5y5a6kj.ffs@tglx> <87353x9y3l.ffs@tglx> <87zg658fla.ffs@tglx> <87r0rg93z5.ffs@tglx> <87cz308y3s.ffs@tglx> Date: Tue, 16 May 2023 14:09:32 +0200 Message-ID: <87y1lo7a0z.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Rspamd-Queue-Id: 2CC0080012 X-Stat-Signature: hcz1jipckffr7c8fuuymeys5br3477tc X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1684238974-561207 X-HE-Meta: U2FsdGVkX18JPVMLZ4h/gzNhZjW3q251cl5loDKC8u7U3eHPQjPLGRfGBnc+p4x0Btddq2kjbNtWAgjlRCe6VMEnDVxjVPjqgYzmY7tuPGrx+JK3KK1oL5n1S2lmwnsRY8WbvxXzTu+5lZUNlq81TnWVUm1MktZwD861NDKi3LRjw+dc09aBC+P7f25oDeA18MpH5S30P1JPRxbTE44cq3r9NP8eAa9wgkPWSBumrinHw8BMYhuh8Gj5PXzQZbXZOT1fuv146xicHqvEFbtO1pKvNlL689udIBru1+su1otGd6ZKhy0YqgJFHoYTpPDGfRQpOuXbu8hl8PV7sWHkuQmyMnP0c2C7Fw40EUz6wM8PANVj433z6Mf9dpvnDzCeUcPX1JXIKudZDWM0qg1lUsYiwCP5vQgnCLHkCklbcE/0FvbBDku4PDT1JPiespGDWbAwQUX929iIqN8BWc2jfaXEUzMOKOzC1auRDQTMBXCnEgvVGimoJsV4YFCstE2wBC2W4mmQNttcueok/ZvGckv1NhHstXj3op3eWI2FSFDQlH/nqH3ABz4AWE7HV6j7ZzG7f8A4sPKNhJclIRxF2qdMM99XCFSQMSM9TViwqnUCcltaAXBmT4Md/1dFyuRCyScj5eOOmESwGc+RAi/bAbUn+lg58bOHlxJUb9WjoTSS0UvVVVdmYfI/NeWLnRWU7qfwLi7wcWjL0Mv4vLomorJ4AXYATOcy/3NC6ntJFeaDIe8Fw1DzlNtlZFHP76a4a/94ag6ruHjTykU0t18ENaOxHwTqZHH/4wdjudEF08JBGpjsHOhFTalFzgFvReMFwDn+DNG1K+AoFxoOdkI2gh5pwYsM5QpuryKjJO/JWttoFFEX6LipsRvL2EfdBc9DVXfYoWFuwmb07sOeolmt4noVfkHirdfzyScDOz71TwuNmfzfHWazWJvIzhGnOyfcpOoMPiWNPQ9O2m41kfd 6VNcG3Up hwrrgpPghsqCnltkvGAtBXtIZgDVQeUT5hM8BT37euxcWj+Y= 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 Tue, May 16 2023 at 09:48, Russell King wrote: > On Tue, May 16, 2023 at 10:44:07AM +0200, Thomas Gleixner wrote: >> On Tue, May 16 2023 at 09:19, Russell King wrote: >> > On Tue, May 16, 2023 at 08:37:18AM +0200, Thomas Gleixner wrote: >> >> void flush_tlb_kernel_vas(struct list_head *list, unsigned int num_entries): >> >> >> >> So that an architecture can decide whether it's worth to do walk the >> >> entries or whether it resorts to a flush all. >> > >> > Is "num_entries" what an arch would want to use? How would it use that? >> > It doesn't tell an arch whether there is a large range of many list >> > entries, or a single entry covering a large range. >> >> Does it matter? >> >> The total number of entries to flush is what accumulates and at some >> architecture specific threshold that becomes more expensive than a full >> flush, independent of the range of the individual list entries, no? > > It depends what you mean by "num_entries" - is that the number of > pages to be flushed in total in the range? Yes. The sum of all va list ranges. > If so, what does a valid "start" and "end" range passed to > __purge_vmap_area_lazy() mean for num_entries - does that go to > (end - start) / PAGE_SIZE, or would it still be restricted to the > sum of that per list entry? If so, what's the point of passing in > "start" and "end" to this function? _vm_unmap_aliases() collects dirty ranges from per cpu vmap_block_queue (what ever that is) and hands a start..end range to __purge_vmap_area_lazy(). As I pointed out already, this can also end up being an excessive range because there is no guarantee that those individual collected ranges are consecutive. Though I have no idea how to cure that right now. AFAICT this was done to spare flush IPIs, but the mm folks should be able to explain that properly. In the problematic case at hand and what I've seen from tracing so far, e.g. for module unload this looks always the same. A small range of direct map collected and then a bunch of vmap entries from the purge list. But have not yet tried hard to figure out whether that direct map collection is ever going to cover a larger range for no reason. Thanks, tglx