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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 15B9CC77B7D for ; Mon, 15 May 2023 18:17:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=SqXZqQTvzlVboEUoY2ihMm+kODYMG8CrXvCvpPT51qU=; b=3X3r7w30RrSLAM RR1hVbJvN0Y78czfCNmy2ldLgizeSbOO23M52e7c7kkdEpdP7G9iCVIklJt5MTL39uHFGkTd06O32 le/9hcftoxYbGFxqs1NJUBa5MM/OT3AUiXgW4786GR4Ao0yR/DorSN6XbQkJyu2vLkWk5Poyij5So OK1fLYPJx9Gv+nT3/tfzZJaLaY9MaVjXVCjBVVpPy2jvffx2dJVROLCUxEOgGkpAaGt1OGVNcsrYh 7jd7EtV+hDtji/G83ooSIQoHDxcVQLpd7KCfA/oG7vKF8PvMZy/qPg3GLT5HfcDklWnlhARq71vgq NQYupmfYBUDdrEuqkigQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pyclH-003753-0b; Mon, 15 May 2023 18:17:31 +0000 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pyclA-0036zr-0g for linux-arm-kernel@lists.infradead.org; Mon, 15 May 2023 18:17:25 +0000 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-4efd6e26585so15120241e87.1 for ; Mon, 15 May 2023 11:17:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684174641; x=1686766641; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc:subject:date:message-id:reply-to; bh=6HEGJfJAxln5y0DnJRlGJvjEHQVuAQaOstuGe/ne06g=; b=K2QWWHbqj09s4trXbxZ0fkbD8+CNnfCiEFW6y7I8czEjONC4POHOiKri1JKW6ev3VB ogGAwBlh61OYgD50AmAwhV2HjVtyHZVTC8ApRRA2o9+XV/ABF7wbvlm396r1imXMettj 8xQ+ULBw7v/5SYY45hHQlPKAZr5zZmwB0LttEOjkzZbN9Kmmx1f8jqkWSC1DbsvnKYCX Vmqh/9AiN575w1sv3OBwm8sJOLTMKb+ffQPTcLBgfDvhLYKJ0ZN5AUShdTGpWXvpWg+u yN5zuefX/WJXZnFqLJdr6x7IxKB48WFxI0Mxb+o9zLACO6uM9Iuxjcz+ZDWdIPkwopCl 3/sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684174641; x=1686766641; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6HEGJfJAxln5y0DnJRlGJvjEHQVuAQaOstuGe/ne06g=; b=JyPA4/vH8UAqOHeEowJopkLtuOEXrpqSbkNq1tHtIaQqPTD/rR/qdpaivMM9mkFngK mtPtFwv/c+rPvbCGxHci0JIhu7Q4RBQP0oZThiUvevXp9FUv/KoM2Ymqyr/PMoT/xX9B s9FU9KoZWQaw4sibWwf8KFc520bi6qzbIaFhCWf2VGvwyoXDlGxEFToAQerODG6oZ7Xo wNGF/zaMHPi32dCOyfo4FlBrRle7wzJqUnELhUUovDeGfzIzhoEeFA5fyYVGCz0V9idl nXOHcBZUGcQBapdETVKgXu8PyDpK+oDSj/q+5efhHPP9vuVCZ75W/joTzG3Bm4wcjpLQ wtpg== X-Gm-Message-State: AC+VfDx0t0D58T5dkKpsE+BPHtpeaXmrJ/1C38T0/NyNgezx1oFSlSRZ 6SHQecNLX+XhPQVbSI121MI= X-Google-Smtp-Source: ACHHUZ5o+rcu7FUrHvPzYrLg+LCLO98WFpCQ8txQV0BorKe7z/7dN1QbElut7ZX80a/nIbzke1Bufw== X-Received: by 2002:ac2:5ecd:0:b0:4f1:30cc:3dae with SMTP id d13-20020ac25ecd000000b004f130cc3daemr6969708lfq.10.1684174640484; Mon, 15 May 2023 11:17:20 -0700 (PDT) Received: from pc636 (host-90-235-18-147.mobileonline.telia.com. [90.235.18.147]) by smtp.gmail.com with ESMTPSA id g11-20020a19ac0b000000b004efd3c2b746sm2639756lfc.162.2023.05.15.11.17.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 11:17:20 -0700 (PDT) From: Uladzislau Rezki X-Google-Original-From: Uladzislau Rezki Date: Mon, 15 May 2023 20:17:17 +0200 To: Thomas Gleixner 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, Russell King , Mark Rutland , Marc Zyngier Subject: Re: Excessive TLB flush ranges Message-ID: References: <87a5y5a6kj.ffs@tglx> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87a5y5a6kj.ffs@tglx> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230515_111724_250701_88D23F58 X-CRM114-Status: GOOD ( 21.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, May 15, 2023 at 06:43:40PM +0200, Thomas Gleixner wrote: > Folks! > > We're observing massive latencies and slowdowns on ARM32 machines due to > excessive TLB flush ranges. > > Those can be observed when tearing down a process, which has a seccomp > BPF filter installed. ARM32 uses the vmalloc area for module space. > > bpf_prog_free_deferred() > vfree() > _vm_unmap_aliases() > collect_per_cpu_vmap_blocks: start:0x95c8d000 end:0x95c8e000 size:0x1000 > __purge_vmap_area_lazy(start:0x95c8d000, end:0x95c8e000) > > va_start:0xf08a1000 va_end:0xf08a5000 size:0x00004000 gap:0x5ac13000 (371731 pages) > va_start:0xf08a5000 va_end:0xf08a9000 size:0x00004000 gap:0x00000000 ( 0 pages) > va_start:0xf08a9000 va_end:0xf08ad000 size:0x00004000 gap:0x00000000 ( 0 pages) > va_start:0xf08ad000 va_end:0xf08b1000 size:0x00004000 gap:0x00000000 ( 0 pages) > va_start:0xf08b3000 va_end:0xf08b7000 size:0x00004000 gap:0x00002000 ( 2 pages) > va_start:0xf08b7000 va_end:0xf08bb000 size:0x00004000 gap:0x00000000 ( 0 pages) > va_start:0xf08bb000 va_end:0xf08bf000 size:0x00004000 gap:0x00000000 ( 0 pages) > va_start:0xf0a15000 va_end:0xf0a17000 size:0x00002000 gap:0x00156000 ( 342 pages) > > flush_tlb_kernel_range(start:0x95c8d000, end:0xf0a17000) > > Does 372106 flush operations where only 31 are useful > > So for all architectures which lack a mechanism to do a full TLB flush > in flush_tlb_kernel_range() this takes ages (4-8ms) and slows down > realtime processes on the other CPUs by a factor of two and larger. > > So while ARM32, CSKY, NIOS, PPC (some variants), _should_ arguably have > a fallback to tlb_flush_all() when the range is too large, there is > another issue. I've seen a couple of instances where _vm_unmap_aliases() > collects one page and the actual va list has only 2 pages, which might > be eventually worth to flush one by one. > > I'm not sure whether that's worth it as checking for those gaps might be > too expensive for the case where a large number of va entries needs to > be flushed. > > We'll experiment with a tlb_flush_all() fallback on that ARM32 system in > the next days and see how that works out. > For systems which lack a full TLB flush and to flush a long range is a problem(it takes time), probably we can flush VA one by one. Because currently we calculate a flush range [min:max] and that range includes the space that might not be mapped at all. Like below: VA_1 VA_2 |....|-------------------------|............| 10 12 60 68 . mapped; - not mapped. so we flush from 10 until 68. Instead, probably we can do a flush of VA_1 range and VA_2 range. On modern systems with many CPUs, it could be a big slow down. Just some thoughts. -- Uladzislau Rezki _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel