Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4097995rdb; Mon, 11 Dec 2023 08:46:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IGyET08/bE9L7+Gra2vEBNL3O3Iu+FG1ddPeESMwnNP93JRl1mVZP9/3YKuO2qlfNp/OIdV X-Received: by 2002:a05:6a00:1c87:b0:6ce:7d6f:cf4d with SMTP id y7-20020a056a001c8700b006ce7d6fcf4dmr2375848pfw.54.1702313196091; Mon, 11 Dec 2023 08:46:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702313196; cv=none; d=google.com; s=arc-20160816; b=TTooR9vuOUfkaUO2Py1Z2OpfAVU1/OORkB7cTuYIw6zu7MrlMV1YagwFnVuQjJQASQ 32wpDrStx0FWc3BWVNw9RCyKUH6840dB5+1ft7GUxtkqu2kPHci1rXLsc06+yqZTUmvj ZI0VRU/I06HmZJIdGlk29EtmEIPp82INW6nRFv+8SW9x9/UB3sUwxXC//cUD8DJK//MD oXX/yUTz/lbtR3kpluu3K4MFvjV0q2STHA0o3/OJSog/mTd+pz1Vz99htyjLzPs3Gu/n 5Q9ZCK166KrvAJtR69lv4c/nYH7rDEo+PRbCOJWxhHMfjkJ37XeKH5jwHV2yHasRik3J 8qTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=noVxPYQYTouWSdFR1RAszjBhMSmcJiRgz0SE80oZI+g=; fh=lbjvIu5YtU1tNM+H+yNSpOa+wxrXuiW1se1TzMxgn70=; b=wgZyKP2aPsyItvebOH8rVJwBry4PgdAueGuWxrUK7P+1LzbaFKgLK1tsUST3vUiacA uGJfhJYqMxakgO2/gZUjIaRzA+JpClI6DLjwAkizt+o2bvMTlR+VQIlAM6VGaUajGvbH 7tF+1H4brsgBMYYwWFyQ8tp1lm8XmwOt0N2dNwGxrM/973xOIs4vmtBfaZkkF7FEbyBh G8v9kyyKJak/lU/xLWrjAGHec2iiGDzrcgnkwIePird9L7lYxWD0jnuyxemBgOIlzA4S v79WJz831d90TjIWTexTFgpnuoYH9aFo9ELoOaRuObmUqfaheEGhuk9Ro8woJD1MGaX+ PkMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hwxyLHl0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id fa1-20020a056a002d0100b006be55174f3fsi6371674pfb.28.2023.12.11.08.46.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 08:46:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hwxyLHl0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id A1EE0809E8E9; Mon, 11 Dec 2023 08:46:33 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344506AbjLKQqV (ORCPT + 99 others); Mon, 11 Dec 2023 11:46:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229625AbjLKQqU (ORCPT ); Mon, 11 Dec 2023 11:46:20 -0500 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66A9991 for ; Mon, 11 Dec 2023 08:46:26 -0800 (PST) Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a1fae88e66eso97879666b.3 for ; Mon, 11 Dec 2023 08:46:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702313185; x=1702917985; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=noVxPYQYTouWSdFR1RAszjBhMSmcJiRgz0SE80oZI+g=; b=hwxyLHl0Cez4tO9u9ZpXAejMyxXvO18jh1SysXrcZzNEqRfZ3NJwJEHXpVCpD59G2O BEZzpHcq5mvUOyGi+cgukrOyAViBxt7AeZozqUKJhY3dUAONpyzvF5Z35UqrUgSwNwGK rNFwIZVqclLQ5myZdsufkF8BOV0zEsmvRDH3pE3ZoL9kOQf3MXMQdG0K0gwa8J4wEczd F5VERA2RQ+qTt1avUqZWJGvUo8D3bItGkhunBQzxsLfGDv3ffUgiTQm0+9iZJVBJrXi7 a8cU+z33BeKTASGRW8+SxticiuP1Jezdyb7YMStYEnCnM5z4jYJXfKLjCHKNbVhLv4BG TRgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702313185; x=1702917985; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=noVxPYQYTouWSdFR1RAszjBhMSmcJiRgz0SE80oZI+g=; b=PqRZ4oBGxwo2DohZOlufj/eXw21P+1KxBzusoosEZ03xikD80dhHwJOiNigfT536V/ A9/SzVB/ACPasO+5DGCteGlt2DKUCijv1SejZBGZqfpW+JSxCtuL9F2T93hoeN/QMFAR ajlWvkx4lGPLbH/O7zD3fT6gniqi9Ruq02aXR1fF6I26JPZ39vQH7vxbLjqVCKxQlSVd oVx44yyQmuxZ3vHvYiZ6dx48CcvMNPQQVfzcpf9g1m7NyZVf4qViGXuJdAdzAv1o1FiM BgNvjHr9eZDVupXMlpmXW5ti9F8zd3As8g6CfM8npOUTeeZ5638w2ZYDnvcV4mD84kRa oong== X-Gm-Message-State: AOJu0YzYvC0CAIp3ah8XfSBSxzDI4haSxQ5IKbVBdjphAoWPdkbFlfrB mVGiR5hR4DhksRQ7T8aJLsg= X-Received: by 2002:a17:907:e8f:b0:a18:b240:915f with SMTP id ho15-20020a1709070e8f00b00a18b240915fmr2571288ejc.69.1702313184563; Mon, 11 Dec 2023 08:46:24 -0800 (PST) Received: from andrea ([31.189.124.152]) by smtp.gmail.com with ESMTPSA id rd12-20020a170907a28c00b00a11b2677acbsm5008366ejc.163.2023.12.11.08.46.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 08:46:24 -0800 (PST) Date: Mon, 11 Dec 2023 17:46:19 +0100 From: Andrea Parri To: Mathieu Desnoyers Cc: paulmck@kernel.org, palmer@dabbelt.com, paul.walmsley@sifive.com, aou@eecs.berkeley.edu, mmaas@google.com, hboehm@google.com, striker@us.ibm.com, charlie@rivosinc.com, rehn@rivosinc.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 3/4] membarrier: riscv: Provide core serializing command Message-ID: References: <20231211094414.8078-1-parri.andrea@gmail.com> <20231211094414.8078-4-parri.andrea@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 11 Dec 2023 08:46:33 -0800 (PST) > > /* > > * The membarrier system call requires a full memory barrier > > * after storing to rq->curr, before going back to user-space. > > + * > > + * The barrier is also needed for the SYNC_CORE command when > > + * switching between processes; in particular, on a transition > > + * from a thread belonging to another mm to a thread belonging > > + * to the mm for which a membarrier SYNC_CORE is done on CPU0: > > + * > > + * - [CPU0] sets all bits in the mm icache_stale_mask. > > + * > > + * - [CPU1] store to rq->curr (by the scheduler). > > + * > > + * - [CPU0] loads rq->curr within membarrier and observes > > + * cpu_rq(1)->curr->mm != mm, so the IPI is skipped on > > + * CPU1; this means membarrier relies on switch_mm() to > > + * issue the sync-core. > > + * > > + * - [CPU1] switch_mm() loads icache_stale_mask; if the bit > > + * is zero, switch_mm() may incorrectly skip the sync-core. > > + * > > + * Matches the full barrier in membarrier_private_expedited(). > > There are two full barriers in membarrier_private_expedited(). We > should clearly state which one it matches, and update the associated > barrier to state that it matches this barrier as well. Agreed, will do. Andrea