Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3024218pxu; Sun, 29 Nov 2020 12:20:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJx5dRfhVq/jtgxz6AfGqbxUp+P0b3qOz037/YM2eyfrV7eOSkJfVCCseJOAwYd1fwjdAuQA X-Received: by 2002:a05:6402:388:: with SMTP id o8mr18417021edv.359.1606681238206; Sun, 29 Nov 2020 12:20:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606681238; cv=none; d=google.com; s=arc-20160816; b=w1/VhoViaqWp8DpWKLwqDpsg5liZR/oXweccf/R0+v/OgzYDmW8vbpaTvkFYYHI8TN AT6C18bGYBvXI5ulyBK2mmF+gzRAzTyVqIk8HBqVxvsGipDJEZUUioDy0hXAyrTRPeLj hEfcxOxYEXjDaTXb0zxdng8t2MhLgI3KGZ1qfNYH7f6paw1iP1ZfwQDAjmri0SBjrodJ vl7mSndjg/C0o52NpVhu3rS0n9khHMGt9lPpFNzDgbP19aSF0atX8hqQ9h2vU2nbYuhI Yab3ycTcvombG4SWakK9tNdUgxF2u5drygywkIZ1q68yy7WdF34PRuazivJfGovM4V4J wvxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=w9vZP6hlvAJ/uxrES28O0fnrnZHiey3h0JHtOzob9iw=; b=MAXArEQSM6krWTpWNjN1twTVDVG4EQzZwkL5wkPl54OLpv2s9eQPyJEryS6bVi0q2k 693q6abCcUBgS9XjDDXmSXO7/ZSwb6xi8abuZDvvd2qmU3TXHrs+vv2nzCijsfmz+RZ5 8uwu0PVHvI6MZG8amkIP/zAyxBXHNIzVG/DyrirwjMBuaEWM06ptYhFV+FgGp3WxafWG YGekNwP5q6e/QoMFkXJrnK0F/ppxMc4mY6rg/dUMk9K2mZd6M2uVUXa0r8cZ9IgEc99+ c4MYZdu9PqGu+HMztZxfAdOFCQXODnbpDdJUC2zSQ/IqmYGeBAV0ToRZTO2O55QYYgk/ s9Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KiuuWU0b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i19si9647198ejk.743.2020.11.29.12.20.15; Sun, 29 Nov 2020 12:20:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KiuuWU0b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727433AbgK2URV (ORCPT + 99 others); Sun, 29 Nov 2020 15:17:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:49742 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727144AbgK2URU (ORCPT ); Sun, 29 Nov 2020 15:17:20 -0500 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C2147208D5 for ; Sun, 29 Nov 2020 20:16:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606681000; bh=N/5rjQqJanCNkJazZn/cQ2aPW49EUqzYQDUy+Xdcge0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=KiuuWU0bKgXhfhotWCf0rYVtbTbBbphVh4LCZHE/dCR9NBCC8GcNZooNBZ5Gi5zU9 PctBfFUnw2EWNN1FkCP1+deRAWJ7usmjY0l2u58A5HXfyVqqdZ5I3lzOC6Z+jAOlZG E77lUb1oMr2CSCePllItgypJ/5XR6/HfDF5zPFlc= Received: by mail-wr1-f45.google.com with SMTP id m6so12509003wrg.7 for ; Sun, 29 Nov 2020 12:16:39 -0800 (PST) X-Gm-Message-State: AOAM533NfObG2631iwpAtTfSHhXHpib/Jf+FNyN2TNaHDpTYGn9imBsa inp0lbgpj3czKYIUxeyzap2CFuKTatBL1sz7564DjQ== X-Received: by 2002:a5d:49ce:: with SMTP id t14mr24072262wrs.75.1606680998232; Sun, 29 Nov 2020 12:16:38 -0800 (PST) MIME-Version: 1.0 References: <20201128160141.1003903-1-npiggin@gmail.com> <20201128160141.1003903-7-npiggin@gmail.com> In-Reply-To: From: Andy Lutomirski Date: Sun, 29 Nov 2020 12:16:26 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 6/8] lazy tlb: shoot lazies, a non-refcounting lazy tlb option To: Andy Lutomirski Cc: Nicholas Piggin , LKML , X86 ML , Mathieu Desnoyers , Arnd Bergmann , Peter Zijlstra , linux-arch , linuxppc-dev , Linux-MM , Anton Blanchard Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Nov 28, 2020 at 7:54 PM Andy Lutomirski wrote: > > On Sat, Nov 28, 2020 at 8:02 AM Nicholas Piggin wrote: > > > > On big systems, the mm refcount can become highly contented when doing > > a lot of context switching with threaded applications (particularly > > switching between the idle thread and an application thread). > > > > Abandoning lazy tlb slows switching down quite a bit in the important > > user->idle->user cases, so so instead implement a non-refcounted scheme > > that causes __mmdrop() to IPI all CPUs in the mm_cpumask and shoot down > > any remaining lazy ones. > > > > Shootdown IPIs are some concern, but they have not been observed to be > > a big problem with this scheme (the powerpc implementation generated > > 314 additional interrupts on a 144 CPU system during a kernel compile). > > There are a number of strategies that could be employed to reduce IPIs > > if they turn out to be a problem for some workload. > > I'm still wondering whether we can do even better. > Hold on a sec.. __mmput() unmaps VMAs, frees pagetables, and flushes the TLB. On x86, this will shoot down all lazies as long as even a single pagetable was freed. (Or at least it will if we don't have a serious bug, but the code seems okay. We'll hit pmd_free_tlb, which sets tlb->freed_tables, which will trigger the IPI.) So, on architectures like x86, the shootdown approach should be free. The only way it ought to have any excess IPIs is if we have CPUs in mm_cpumask() that don't need IPI to free pagetables, which could happen on paravirt. Can you try to figure out why you saw any increase in IPIs? It would be nice if we can make the new code unconditional.