Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1314039ybh; Thu, 16 Jul 2020 08:47:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUmz1Dp+tMAmuCv2fuQweObob/s/XP4xMCqJJhGeilvJMM7TND94KrhpWO1t3hAmsgKejC X-Received: by 2002:a05:6402:1d18:: with SMTP id dg24mr5087995edb.33.1594914472605; Thu, 16 Jul 2020 08:47:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594914472; cv=none; d=google.com; s=arc-20160816; b=mLahWNf+Ci+13VirQSZjPDHZVSlGzQfXebQiUXOvQLJ7tYQdRstnSljVRFk4qDAljh jttpe7A7/h/du2IhVLKKfpmRcTcxOMWJJQILCCnWf7WAxzOItGKcrRp67TiM5DFWRejh ZXgRyHH66QHqnaRl9W5hOvU+4FlS0MYPLkL1NarT5DjU7Pg8N+CnwcAxI9+No6szozGb HicJ4WPSmpYLuJukXNCTqLybRjgONS8d8wr7AupL0xgct0iClUvykYYm1hipFg6NnUHo GcXQs+lGKpD5mzebvCtIs+Q/0ZiEvrc7KZe1aMj+1LhlnF0sbiUB+VDESg/DDHfTaxGB uQ2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:dkim-signature:dkim-filter; bh=vp71nmZTDnneRvjCieT0x9SqYt8j1qCXpo2gjxlL3so=; b=b9StFmIpliGHWXxkJh5+nqllH5pwwn9IPSK7504o7997qHpwkgQc3Fo7BbSm5+u/Ob hLUpY1yy+WG5hWtNtlijzjA/s9pC09iQY2qapdNP/rP3EiSZS8yh7oUPSB44Pi+L/oQ0 k8xss4wg8+mVsMg/K+pmc0V4KOlybC1m7XMwpOpL5fLYBJR0pyh6pTv2mHOen9AnRUJO Zd4bcRI1Vvs9MUGhRNIw56CsxInX3ab8chuvY30STb9DJNGC4S5jytIDrx4Z1JyNxr20 r12s7Jy5ewm61l+c36LJ/clA4wasrRhYfitfyqjX4FfDZSvf3B0cYvVH1kFOuu+QfdvP HUJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=K0GdpyhC; 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=efficios.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id de21si3388959edb.510.2020.07.16.08.47.28; Thu, 16 Jul 2020 08:47:52 -0700 (PDT) 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=@efficios.com header.s=default header.b=K0GdpyhC; 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=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729096AbgGPPqY (ORCPT + 99 others); Thu, 16 Jul 2020 11:46:24 -0400 Received: from mail.efficios.com ([167.114.26.124]:41972 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728589AbgGPPqY (ORCPT ); Thu, 16 Jul 2020 11:46:24 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 159EB295C14; Thu, 16 Jul 2020 11:46:23 -0400 (EDT) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id Ync1L2q1T9lv; Thu, 16 Jul 2020 11:46:22 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id CA374295C12; Thu, 16 Jul 2020 11:46:22 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com CA374295C12 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1594914382; bh=vp71nmZTDnneRvjCieT0x9SqYt8j1qCXpo2gjxlL3so=; h=Date:From:To:Message-ID:MIME-Version; b=K0GdpyhCRtALmYLXIh6DsJqf5JNfl+RI9XMaZP0aXJxChWcSX9OVVieyRrXb0RdNF /Jipc4A5/RnMwjqyEEjMbVvPgdIyqg6mfSDPHwU7+bVACA16/s7rBD/5S9Ry3GzbYz zozOXqGhRXMR7LQsMhcMdCiJxv4UqQcKzv23U33hh7+oS3VAGnpLQ7djUioTHcUXDS rK/z3rkvdslH/xm8AnVlglCB7mUKCwPJ2Wa5dCSeWU5gFMxAxZAqzIFqfrTeE61LmU I7C30UDlbJOPkIN+i5Daj+lxxaCposb7B788MeCho+Z3GlA44nFE/aH+PkU8QPciwE N4uKpWyshlp+Q== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id LKw2bNJbhb-0; Thu, 16 Jul 2020 11:46:22 -0400 (EDT) Received: from mail03.efficios.com (mail03.efficios.com [167.114.26.124]) by mail.efficios.com (Postfix) with ESMTP id BE0E2295C10; Thu, 16 Jul 2020 11:46:22 -0400 (EDT) Date: Thu, 16 Jul 2020 11:46:22 -0400 (EDT) From: Mathieu Desnoyers To: Nicholas Piggin Cc: Anton Blanchard , Arnd Bergmann , linux-arch , linux-kernel , linux-mm , linuxppc-dev , Andy Lutomirski , Peter Zijlstra , x86 Message-ID: <1494299304.15894.1594914382695.JavaMail.zimbra@efficios.com> In-Reply-To: <1594873644.viept6os6j.astroid@bobo.none> References: <20200710015646.2020871-1-npiggin@gmail.com> <20200710015646.2020871-5-npiggin@gmail.com> <1594613902.1wzayj0p15.astroid@bobo.none> <1594647408.wmrazhwjzb.astroid@bobo.none> <284592761.9860.1594649601492.JavaMail.zimbra@efficios.com> <1594868476.6k5kvx8684.astroid@bobo.none> <1594873644.viept6os6j.astroid@bobo.none> Subject: Re: [RFC PATCH 4/7] x86: use exit_lazy_tlb rather than membarrier_mm_sync_core_before_usermode MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.26.124] X-Mailer: Zimbra 8.8.15_GA_3955 (ZimbraWebClient - FF78 (Linux)/8.8.15_GA_3953) Thread-Topic: x86: use exit_lazy_tlb rather than membarrier_mm_sync_core_before_usermode Thread-Index: cb6zdS0KPjkbq8hxmgetruE+ExgftQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Jul 16, 2020, at 12:42 AM, Nicholas Piggin npiggin@gmail.com wrote: > I should be more complete here, especially since I was complaining > about unclear barrier comment :) > > > CPU0 CPU1 > a. user stuff 1. user stuff > b. membarrier() 2. enter kernel > c. smp_mb() 3. smp_mb__after_spinlock(); // in __schedule > d. read rq->curr 4. rq->curr switched to kthread > e. is kthread, skip IPI 5. switch_to kthread > f. return to user 6. rq->curr switched to user thread > g. user stuff 7. switch_to user thread > 8. exit kernel > 9. more user stuff > > What you're really ordering is a, g vs 1, 9 right? > > In other words, 9 must see a if it sees g, g must see 1 if it saw 9, > etc. > > Userspace does not care where the barriers are exactly or what kernel > memory accesses might be being ordered by them, so long as there is a > mb somewhere between a and g, and 1 and 9. Right? This is correct. Note that the accesses to user-space memory can be done either by user-space code or kernel code, it doesn't matter. However, in order to be considered as happening before/after either membarrier or the matching compiler barrier, kernel code needs to have causality relationship with user-space execution, e.g. user-space does a system call, or returns from a system call. In the case of io_uring, submitting a request or returning from waiting on request completion appear to provide this causality relationship. Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com