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 2623FC433EF for ; Sun, 9 Jan 2022 08:49:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8754D6B0072; Sun, 9 Jan 2022 03:49:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7FEE86B0073; Sun, 9 Jan 2022 03:49:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 677D86B0074; Sun, 9 Jan 2022 03:49:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0172.hostedemail.com [216.40.44.172]) by kanga.kvack.org (Postfix) with ESMTP id 53F536B0072 for ; Sun, 9 Jan 2022 03:49:10 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id F013E1808E31C for ; Sun, 9 Jan 2022 08:49:09 +0000 (UTC) X-FDA: 79010124018.29.AB356B2 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by imf04.hostedemail.com (Postfix) with ESMTP id 77BEB40011 for ; Sun, 9 Jan 2022 08:49:09 +0000 (UTC) Received: by mail-pf1-f179.google.com with SMTP id w204so140133pfc.7 for ; Sun, 09 Jan 2022 00:49:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=o9EmHZcSICKN316fHMY91MizRyPQShQCNbAS0hB713c=; b=XYpfUt383JWJwGaKWZpAKdo+YiAFBQ5m/K4QI6Tne9Whlr0hkgZwS9tvANsRb4ENTK jqvkZCoyQRExqElL0pgO2DleCTZSlnnSXQmS057zcjyB4kw7w3ARhRZm1fiBg7jH9GtL zCJuzLANVVdTJ5pFBLn0d62zhCCUj80qr1QlwnNxiiJ/HtKz8soDFznLgZ5UMiVAsu33 pdRL0eImc8vQlH3I6U96B+8mD0nSeyA23HgCDOCyXNqzdHLlOMXXcNr2MlFkSflf7y5Z G584l0qyC8KYW+kJZDfa69zndj+MqgtypqUHo9pmUonJ/9/st8mCX14r5ooGHskfg/WC vs3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=o9EmHZcSICKN316fHMY91MizRyPQShQCNbAS0hB713c=; b=YZjl//tnOfvrF/vwDX99V2Xi6W2+L3L7qi+oc1uHtKSuSKRtWaxcCFbBdlDI5VyDV3 rXWM2Ymb31tdvT1EJG4NCq9Mqq1sSkx1Y+IbFyKgKew0tDFmdd75X8/CDgzzwatQtz8o M6U49EKfDG8at+uVXrrgh3jCxo+vckn8cYqDwQwqf6DFS4h63WiarkwpMV4aRBdFftWs aKhq2DaShnSwr76rxKPtGep+M13IX7Dzj1WghYIqyTAIUK21yhYU3orvrkk7Ts91CqCS 1iKe3De1Xm3l90zPoY9wShtuR40eJLPdfp5UNA+KFPsJYY/f4zBEPiSjouxNEWneBUI4 lhSA== X-Gm-Message-State: AOAM532HnTPBJza8axJJgVv4/RDpO8Fn+UdqrWEfRQJzMYOh8Z9HkewC /91/mLdO4fGBSxreU/YgSC4= X-Google-Smtp-Source: ABdhPJw54hlsdqK5QlC8xHoSFSJbx4qK6uGUtHw76Ab4RaLHRTPSSAtuWGbuy+FRrO+Ni/5OI8XHmw== X-Received: by 2002:a63:9544:: with SMTP id t4mr4391363pgn.175.1641718148228; Sun, 09 Jan 2022 00:49:08 -0800 (PST) Received: from smtpclient.apple (c-24-6-216-183.hsd1.ca.comcast.net. [24.6.216.183]) by smtp.gmail.com with ESMTPSA id x19sm2545676pgi.19.2022.01.09.00.49.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Jan 2022 00:49:07 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: [PATCH 16/23] sched: Use lightweight hazard pointers to grab lazy mms From: Nadav Amit In-Reply-To: Date: Sun, 9 Jan 2022 00:49:06 -0800 Cc: Andrew Morton , Linux-MM , Nicholas Piggin , Anton Blanchard , Benjamin Herrenschmidt , Paul Mackerras , Randy Dunlap , linux-arch , X86 ML , Rik van Riel , Dave Hansen , Peter Zijlstra , Mathieu Desnoyers Content-Transfer-Encoding: quoted-printable Message-Id: References: <7c9c388c388df8e88bb5d14828053ac0cb11cf69.1641659630.git.luto@kernel.org> <739A3109-04DD-4BA5-A02B-52EE30E820AE@gmail.com> To: Linus Torvalds , Andy Lutomirski X-Mailer: Apple Mail (2.3654.120.0.1.13) X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 77BEB40011 X-Stat-Signature: scp9y7gkqj1hbgwo5h3ddz69nszeejao Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=XYpfUt38; spf=pass (imf04.hostedemail.com: domain of nadav.amit@gmail.com designates 209.85.210.179 as permitted sender) smtp.mailfrom=nadav.amit@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1641718149-194311 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 Jan 8, 2022, at 10:48 PM, Linus Torvalds = wrote: >=20 > On Sat, Jan 8, 2022 at 9:56 PM Nadav Amit = wrote: >>=20 >> Just wondering: In a world of ASID/PCID - does the =E2=80=9Clazy = TLB=E2=80=9D really >> have a worthy advantage? >>=20 >> Considering the fact that with PTI anyhow address spaces are switched >> all the time, can=E2=80=99t we just get rid of it? >=20 [snip] >=20 > Or maybe it's only worth it on platforms where it's free (UP, possibly > other situations - like if you have IPI and it's "free"). On UP it might be free, but on x86+IPIs there is a tradeoff. When you decide which CPUs you want to send the IPI to, in the common flow (no tables freed) you check whether they use =E2=80=9Clazy TLB=E2=80=9D or not in order to filter out the lazy ones. = In the past this was on a cacheline with other frequently-dirtied data so many times the cacheline bounced from cache to cache. Worse, the test used an indirect branch so was expensive with Spectre v2 mitigations. I fixed it some time ago, so things are better and today the cacheline of is_lazy should bounce less between caches, but there is a tradeoff in maintaining and checking both cpumask and then is_lazy for each CPU in cpumask. It is possible for instance to get rid of is_lazy, keep the CPU on mm_cpumask when switching to kernel thread, and then if/when an IPI is received remove it from cpumask to avoid further unnecessary TLB shootdown IPIs. I do not know whether it is a pure win, but there is a tradeoff.=