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 X-Spam-Level: X-Spam-Status: No, score=-7.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72E2CC64E7B for ; Sun, 29 Nov 2020 20:16:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E254620756 for ; Sun, 29 Nov 2020 20:16:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="KiuuWU0b" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E254620756 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1056E6B0036; Sun, 29 Nov 2020 15:16:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0914C6B005D; Sun, 29 Nov 2020 15:16:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E4ACC6B0068; Sun, 29 Nov 2020 15:16:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0194.hostedemail.com [216.40.44.194]) by kanga.kvack.org (Postfix) with ESMTP id C97646B0036 for ; Sun, 29 Nov 2020 15:16:41 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 89A38181AEF23 for ; Sun, 29 Nov 2020 20:16:41 +0000 (UTC) X-FDA: 77538563802.09.sun12_01076392739c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id 6DF59180AD81F for ; Sun, 29 Nov 2020 20:16:41 +0000 (UTC) X-HE-Tag: sun12_01076392739c X-Filterd-Recvd-Size: 4237 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Sun, 29 Nov 2020 20:16:40 +0000 (UTC) Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (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 ABBB420786 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-f43.google.com with SMTP id s8so12499930wrw.10 for ; Sun, 29 Nov 2020 12:16:39 -0800 (PST) X-Gm-Message-State: AOAM530UNRhhY0FQ6XezbQH2ALQBNr/DA+DP2v/YzuXviiwoLJyWcNEB Iqm/2XS4tzhLpIAvysgHlFjHqwLL2ypdmU/m77FCRQ== X-Google-Smtp-Source: ABdhPJwYikNyF98Tybzh36itlesMK1rlfrvxImOMUWZkk0NuWSWbLwn6lWsiusLeR7vr43/6ZfjVImZ+tuEfqHGf3aM= 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" 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 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.