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=-2.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,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 10D17C64E8A for ; Wed, 2 Dec 2020 02:50:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6BD44206F9 for ; Wed, 2 Dec 2020 02:50:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6BD44206F9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CAF7B6B005D; Tue, 1 Dec 2020 21:50:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C602D6B0068; Tue, 1 Dec 2020 21:50:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AFD208D0001; Tue, 1 Dec 2020 21:50:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0086.hostedemail.com [216.40.44.86]) by kanga.kvack.org (Postfix) with ESMTP id 94F6A6B005D for ; Tue, 1 Dec 2020 21:50:03 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 511F81EF2 for ; Wed, 2 Dec 2020 02:50:03 +0000 (UTC) X-FDA: 77546812686.01.grade92_480d738273af Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id 3599F1004D5BB for ; Wed, 2 Dec 2020 02:50:03 +0000 (UTC) X-HE-Tag: grade92_480d738273af X-Filterd-Recvd-Size: 5499 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Wed, 2 Dec 2020 02:50:02 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id j13so146235pjz.3 for ; Tue, 01 Dec 2020 18:50:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:references:in-reply-to:mime-version :message-id:content-transfer-encoding; bh=cQulqwTG5/+FKQNusgjvEPfQ8LJuFbT6VbTDryDflxw=; b=gswJVu4rOSQ8N4hID+k14MxofbGrn5oUbk4d+sSDWLmSmpTKLtWi+wskJUT4fc7hTC LeY6if6Fh6DblFlCGLNq24vdipRHhKBkzdyk76Zh0EAiLjC4PJ2TX/ZnZgp9VnKXJI22 BYXUeYA/o38Ik42izjE7nN3DDJcO7dMThBErfVvlf1CIe2agS2ZZBLb9g01E00o4n4A1 itDLc51pNSjHuLF8gQYRTM0xJs+Fga0hsGUJbxfdM6zdAo/2C2crcRVk/lKqVzk5HrJh uHpGzUvQHbeAC4DyFaPk/aKY2B6+npKJkwFyL0Oqfy1rH96rWPrWFzrbsEjZGAXEUsF1 im8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:references:in-reply-to :mime-version:message-id:content-transfer-encoding; bh=cQulqwTG5/+FKQNusgjvEPfQ8LJuFbT6VbTDryDflxw=; b=b585y1XmZbAreyeWIpt1sQ9SkpekuI9v+rCTOrpSfRhX1Z3UK2IHsh5Rt7CFQWYEUi kmVVr6f+jDaWod83CeYnVZT8IWdXcMnU8OepJ8Z+mSgD+ejCrjR6JxV3jUcFkyMy237g Vg1WF+iH7+jr7d2wr6fukeNtCF7v4diALqlVRuj0MZ6DdGrOQaelEjxKm8FpJPjTyLVm aj1GA02NhyppfeRgWMmVtSbrG9qugp3NIkQJwX95GGeHSyhiKAbnI1bIsBiG3vSrSmQu lYRZGieHzM/Y3M5VAaBtvgijC9jqz/PK/G2gbA5WV90HBeQnhwy2CDuL3ufPca/lsRN9 DS5w== X-Gm-Message-State: AOAM5331rQ9capdH9Z3DHrEO/aoBDfekkTQi33pkwctZjAKEOapAwGQa CS9pBHcx+W2UvZl7njcIy7M= X-Google-Smtp-Source: ABdhPJwgLHQbFa4c6y7A2FXBrGv4J5hKeX6Te1QlRRdopHTV/3PR/OFLgCF3bk/OzO6mk4nBSzftsA== X-Received: by 2002:a17:902:e787:b029:d9:f88d:c32d with SMTP id cp7-20020a170902e787b02900d9f88dc32dmr603516plb.79.1606877401804; Tue, 01 Dec 2020 18:50:01 -0800 (PST) Received: from localhost ([1.132.177.56]) by smtp.gmail.com with ESMTPSA id u24sm290208pfm.51.2020.12.01.18.49.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2020 18:50:00 -0800 (PST) Date: Wed, 02 Dec 2020 12:49:53 +1000 From: Nicholas Piggin Subject: Re: [PATCH 2/8] x86: use exit_lazy_tlb rather than membarrier_mm_sync_core_before_usermode To: Andy Lutomirski Cc: Anton Blanchard , Arnd Bergmann , linux-arch , LKML , Linux-MM , linuxppc-dev , Mathieu Desnoyers , Peter Zijlstra , X86 ML References: <20201128160141.1003903-1-npiggin@gmail.com> <20201128160141.1003903-3-npiggin@gmail.com> In-Reply-To: MIME-Version: 1.0 Message-Id: <1606876327.dyrhkih2kh.astroid@bobo.none> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: Excerpts from Andy Lutomirski's message of November 29, 2020 3:55 am: > On Sat, Nov 28, 2020 at 8:02 AM Nicholas Piggin wrote= : >> >> And get rid of the generic sync_core_before_usermode facility. This is >> functionally a no-op in the core scheduler code, but it also catches >> >> This helper is the wrong way around I think. The idea that membarrier >> state requires a core sync before returning to user is the easy one >> that does not need hiding behind membarrier calls. The gap in core >> synchronization due to x86's sysret/sysexit and lazy tlb mode, is the >> tricky detail that is better put in x86 lazy tlb code. >> >> Consider if an arch did not synchronize core in switch_mm either, then >> membarrier_mm_sync_core_before_usermode would be in the wrong place >> but arch specific mmu context functions would still be the right place. >> There is also a exit_lazy_tlb case that is not covered by this call, whi= ch >> could be a bugs (kthread use mm the membarrier process's mm then context >> switch back to the process without switching mm or lazy mm switch). >> >> This makes lazy tlb code a bit more modular. >=20 > I have a couple of membarrier fixes that I want to send out today or > tomorrow, and they might eliminate the need for this patch. Let me > think about this a little bit. I'll cc you. The existing code is way > to subtle and the comments are far too confusing for me to be quickly > confident about any of my conclusions :) >=20 Thanks for the head's up. I'll have to have a better look through them=20 but I don't know that it eliminates the need for this entirely although it might close some gaps and make this not a bug fix. The problem here=20 is x86 code wanted something to be called when a lazy mm is unlazied, but it missed some spots and also the core scheduler doesn't need to=20 know about those x86 details if it has this generic call that annotates the lazy handling better. I'll go through the wording again and look at your patches a bit better but I think they are somewhat orthogonal. Thanks, Nick