Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2426460pxa; Fri, 7 Aug 2020 10:49:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJziVLKbiBUkP2dzKFk5leUdslHyBQkB5EjYpnHWmLl8t8mvBDJ0kwk4PgoN2byPxYFAMTdS X-Received: by 2002:a17:906:1cd4:: with SMTP id i20mr10187548ejh.480.1596822592330; Fri, 07 Aug 2020 10:49:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596822592; cv=none; d=google.com; s=arc-20160816; b=DXydq75fBpt3JLzlYaLpegRVhjgp9f+5AKfDSH4jphYHxztp4tjS0CDv2m+2zt789Q 1EbNRuLdF5Q++Fc3O6q8HfOcBu9baLU8C5BoG4EuXd+Uzyv6PaXkYUNiXaEm+LQCLZTN mAYeOXdm9gWqIn9DmHQCkdD7/ntk4gA2uKrnhB+b0zbySFj3Aue5Gl1Oz+MiEqZipUM6 UyXZT1AjkpacpmkuyWugxPAEDWvIewY/BrZwKBOkvA2aMX/46GpflJGq620JxLXMJ80M k3IUOpiHV6bM31vJQReZo7etHNWigBQAh0zM+KBoyBCKLf4Fe0P4NQ8CH49pmvObccoC tIDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=a1jD6vSBcep9pVCJ88Buz+hBFmqHCHo08h2XlXM8iY4=; b=n9RujDFPgwYbNVMyyrWUdwC2lCKG4Bq9QneRkg97wjX6DZcIx4S6WjP+Jke/YhLRlI qGskY9DZC8xZBuIk0XuW20h/QveIbXXyrm6fe7OulG6sY5aMudMRj2J3UrwITl/0ojWe p1h6O9Wudh0ewZIH920rKfmRnEwArh7CQ4aBG5xiL2Vwg4VGbQ0dYG4lDgo7CX0hhAql Sgm8XIZsnmtHv/w07kR6m8Zz3G+O/WCRzvbR5IzEcHepsg1x98k3Nq5IyXHGr1SNL78m X1wef85cOpTmyJbYS2y5n4/SQmJ5xly9ol+jd/Z5F7WKO4Z8MT/MwhA7m/RNGHGq+Jlg f2Ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@posk.io header.s=google header.b=gb9t2ERu; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n9si5678327eji.444.2020.08.07.10.49.28; Fri, 07 Aug 2020 10:49: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=@posk.io header.s=google header.b=gb9t2ERu; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727824AbgHGRsw (ORCPT + 99 others); Fri, 7 Aug 2020 13:48:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727032AbgHGRsm (ORCPT ); Fri, 7 Aug 2020 13:48:42 -0400 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4FD2C061756 for ; Fri, 7 Aug 2020 10:48:41 -0700 (PDT) Received: by mail-ed1-x544.google.com with SMTP id m20so1860028eds.2 for ; Fri, 07 Aug 2020 10:48:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=posk.io; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=a1jD6vSBcep9pVCJ88Buz+hBFmqHCHo08h2XlXM8iY4=; b=gb9t2ERu8IGQ6tNi0ZxR5nubtWLAqXc/EC2R0cU+LNABC6fdMKUqGGuhMQP0aWtcCr NOKutwU0d8AkYJXjJXuM2W9PFhd13h+jbpI3nfdH9TokAxxU9XfeWLSfLxOCo4OqveqB H710NTxC1CkGCJ7VnCqPMxWgyNlwqr0P23OuSyBHGHR6la4eWqMXbepAyn76UVVZy7A5 iiXoP/bDwyn+c6oNCs8wE8nWf9+LFHaD2tlHh8/DgD2FigydwUAcj/SCw5vL4xPPCMRa PITZdOXFlNEWqRPX2QlV3kMoGtUvWw/H5YMCdi4FG1Y6E6ON3sRSByJclSbKmu2ZkvW5 Rblg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=a1jD6vSBcep9pVCJ88Buz+hBFmqHCHo08h2XlXM8iY4=; b=r2wOmoQqZp95UiRSEU7r5IhU3dyTe6fln+r4ijRLoizPi9hMISOFSTa49eGRg0CYo5 SyGhOEsk25hMvx5Bd1Sw9H2enP9BrSjGrFeVaycRKJyqSrlYPoxkmWegFKHLGWXHQMYL 3hP2bnFxZ8rTzUY2NfmjkwMst+LNpKt156FEMpV5plFJDaNz3t++MZ8hV1RMK3OK/iQA TmmBrez/H8Zuk6AdrMytB6czTzIBon6l3vH/oMyNQmK3ewHjG67AyuTp784XeXPN25Yb wJD5ZCGCogfrEVCA5lLKesMmAjNea8RZzqqBhLWtX342ypoExKT27EZES7ZIvTZs4Sbf 2YOA== X-Gm-Message-State: AOAM531uFpksFXhFbFvoCOxVouCD/QE9k3wh+TVW3KNUgYf1r7+hA+Q+ C6tMlL0jDhD0Kc+JnAAZaqNNgSynXqv0MUmh11YZAg== X-Received: by 2002:a50:93a2:: with SMTP id o31mr10054666eda.203.1596822520037; Fri, 07 Aug 2020 10:48:40 -0700 (PDT) MIME-Version: 1.0 References: <20200806000859.160882-1-posk@google.com> <20200806134828.GA165568@hirez.programming.kicks-ass.net> <1668913120.1621.1596735425601.JavaMail.zimbra@efficios.com> In-Reply-To: <1668913120.1621.1596735425601.JavaMail.zimbra@efficios.com> From: Peter Oskolkov Date: Fri, 7 Aug 2020 10:48:29 -0700 Message-ID: Subject: Re: [PATCH 1/2] membarrier: add MEMBARRIER_CMD_PRIVATE_RESTART_RSEQ_ON_CPU To: Mathieu Desnoyers Cc: Peter Zijlstra , Peter Oskolkov , paulmck , linux-kernel , Paul Turner , Chris Kennelly Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 6, 2020 at 10:37 AM Mathieu Desnoyers wrote: > > >> > >> This is an unpriv IPI the world. That's a big no-no. > > > > removed in v2. > > I don't think the feature must be removed, but its implementation needs adjustment. > > How about we simply piggy-back on the membarrier schemes we already have, and > implement: > > membarrier_register_private_expedited(MEMBARRIER_FLAG_RSEQ) > membarrier_private_expedited(MEMBARRIER_FLAG_RSEQ) > > All the logic is there to prevent sending IPIs to runqueues which are not running > threads associated with the same mm. Considering that preemption does an rseq abort, > running a thread belonging to a different mm should mean that this CPU is not > currently executing an rseq critical section, or if it was, it has already been > aborted, so it is quiescent. > > Then you'll probably want to change membarrier_private_expedited so it takes an > extra "cpu" argument. If cpu=-1, iterate on all runqueues like we currently do. > If cpu >= 0, only IPI that CPU if the thread currently running has the same mm. > Thanks, Mathieu! I'll prepare something based on your and Peter's feedback. > Also, should this belong to the membarrier or the rseq system call ? It just > looks like the membarrier happens to implement very similar things for barriers, > but arguably this is really about rseq. I wonder if we should expose this through > rseq instead, even if we end up using membarrier code. Yes, this is more about rseq; on the other hand, the high-level API/behavior looks closer to that membarrier, and a lot of code will be shared. As you are the maintainer for both rseq and membarrier, this is for you to decide, I guess... :)