Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4048589ybz; Mon, 20 Apr 2020 14:38:47 -0700 (PDT) X-Google-Smtp-Source: APiQypKxF1WsqP9oizMg40fPH+eJ2kiagdChT0VR7CJ33tV93gmNsHqV4SFGHJCtCJd1tgiwP5Dk X-Received: by 2002:a17:906:4ecd:: with SMTP id i13mr17982763ejv.68.1587418727033; Mon, 20 Apr 2020 14:38:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587418727; cv=none; d=google.com; s=arc-20160816; b=qiwYdczrYLf7g+YBlckZIZWpOJ/ASdFqrhQqxxJ+TY+LhtNXcUKCuINK4s19NahkCA FlptC7K+E6u93WubyX95a7/jUw1sgy91seiyA3AUCl8NFvn+Ab8QPigkedbAJ3MSbw2j 9QQOpcPvoft7V0Qh16JqPZGwpSY+UwAuaInqcIVsQxvfDXbZMP1nUBOJQPAiS8jnQGnE IDM9rxrgiboHgTbie41NHhIoG8Ag4jrF3qmOvG+X/pXMj7vq3n4eFLoZr+FosPrAktwj NNsiRGZ6lVd6l4y+3eY0zlwaVfCPowP3zVI7S4Jl9vC0d0fcxc+hPVx4QX5rZx1Vq/yc /fdw== 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=CGpR1rIaKdDduSGmslkbgwO1HLCBO6wZTx9DKYZPcys=; b=FCi4GYK2H77vk8i85UuZxwvuelQ8XeazU7j8vxXS0XHZIMlxPg2JCwL/wT5dv6yTYU V2ARBTyn3quFopWBQB5zfFvnABGrn7loM9Dbpax8ue6bJIKeoJOcFouaC/iGhZCa8FBh WfX0B8eyfWsyW9cEm3oJVIgG5LUqF11TAufRlwg8tZpuv/gnvkKy4VIVXfkxHG5kC3W0 Le1zRLFk6exCsXbj24OF2dAKEZzuUxoEwFxLxl6Ol7Ah4RSOajtyUrHl64pFT4lOJd/C aZvsrpyWqXDXxyIfL/or8js1GS5RKfaSH1azH0lDhCx1rgzyhnY+ZZgCNWHKZcSch0Xk HVfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=P8vJiVfM; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u2si305447ejr.370.2020.04.20.14.38.23; Mon, 20 Apr 2020 14:38:47 -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=@google.com header.s=20161025 header.b=P8vJiVfM; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727001AbgDTVhD (ORCPT + 99 others); Mon, 20 Apr 2020 17:37:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726017AbgDTVhC (ORCPT ); Mon, 20 Apr 2020 17:37:02 -0400 Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CA97C061A0C for ; Mon, 20 Apr 2020 14:37:02 -0700 (PDT) Received: by mail-qt1-x844.google.com with SMTP id w29so9968516qtv.3 for ; Mon, 20 Apr 2020 14:37:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CGpR1rIaKdDduSGmslkbgwO1HLCBO6wZTx9DKYZPcys=; b=P8vJiVfMaQcO0jKGtW7wH+FAbz8kXDXPqrJWejAU0NGX4Cgjg/9Cu1iHQyAMgY5kO5 5nhJbfjZRWuWpz41LXkq2xCBD1LcxaT3rQoQSUYKwotBwFvjroSAhYiHMc82PwQZswLg UT6XCOrBFry8UdNu/tc4aC+eySS3HLPKGT0dLPMztZKg0P7s4QqmWX4fDcykPK4ne/dS yCEjv/VlPjMStwqvMiZCXte/76PwTVVF//S4qhmHDJbkxsRh0Q2R/6a9KcP79PHVyqSf ApGR9P0NyQ4DlduFCRO0HkQLACFqywkhdrjYEFFFT6S2QsOUxXuA3JUK2iYGHAdDLFmN ysiw== 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=CGpR1rIaKdDduSGmslkbgwO1HLCBO6wZTx9DKYZPcys=; b=Br8BSUS2UWUh/YxsCPTerEDVAC6cZKTqobfNJ/5hHEjaJ6o465v2sEfjDVksvKAAcI 1qtuSsDHiOehPJ4C/t2uFergNX8xiEGs68iSiTnFQs1q4pqVHPoAz01rxhAmlcqpx8IK em3Le7jcdb0hcz7lotvs3pnvcI6xnBlFGXZDQy0RhSsMCtkp98TFnSoADqc5uk7IuNDv J9gLiVRSgDVTa682bwk12jvAYYSLSP4FTE/WcGRl6xntlttAVudKlOJoPqot/RsTf+6A esBdc+EtrdLvm/PtUi7amyc+oxKd/N+pzx/n5BEkRoLykHZ/ggBMKn/ckHPPHu5v/ZBX 5EDw== X-Gm-Message-State: AGi0PuZ5dxumhNl7DaVUUyHbIC61cpfP6qd9+zB2OfnHfyub/aP8hvyS TUwnNwhstqKvP5hHl1cdWMtAGq6Ize/gGR5UPRINqw== X-Received: by 2002:ac8:748b:: with SMTP id v11mr18067843qtq.238.1587418621139; Mon, 20 Apr 2020 14:37:01 -0700 (PDT) MIME-Version: 1.0 References: <20200414150556.10920-1-qais.yousef@arm.com> <20200414150556.10920-3-qais.yousef@arm.com> <20200414121956.3687d6e9@gandalf.local.home> <20200415093617.GZ20730@hirez.programming.kicks-ass.net> <20200420154317.klwoztvdybmvykwe@e107158-lin.cambridge.arm.com> In-Reply-To: <20200420154317.klwoztvdybmvykwe@e107158-lin.cambridge.arm.com> From: Josh Don Date: Mon, 20 Apr 2020 14:36:49 -0700 Message-ID: Subject: Re: [PATCH 2/4] cpumask: Make cpumask_any() truly random To: Qais Yousef Cc: Peter Zijlstra , Steven Rostedt , Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Andrew Morton , Thomas Gleixner , Yury Norov , Paul Turner , Alexey Dobriyan , Pavan Kondeti , linux-kernel 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 Mon, Apr 20, 2020 at 8:43 AM Qais Yousef wrote: > > On 04/15/20 11:36, Peter Zijlstra wrote: > > On Tue, Apr 14, 2020 at 12:19:56PM -0400, Steven Rostedt wrote: > > > Do we care if this gets preempted and migrated to a new CPU where we read > > > "prev" from one distribute_cpu_mask_prev on one CPU and write it to another > > > CPU? > > > > I don't think we do; that just adds to the randomness ;-), but you do > > Yep we don't care and it should enhance the randomness. > > > raise a good point in that __this_cpu_*() ops assume preemption is > > already disabled, which is true of the one exiting > > cpumask_any_and_distribute() caller, but is no longer true after patch > > 1, and this patch repeats the mistake. > > > > So either we need to disable preemption across the function or > > transition to this_cpu_*() ops. > > Sorry wasn't aware about the preemption check in __this_cpu_write(). > > Transitioning to this_cpu_write() makes sense. Unless Josh comes back it'll > break something he noticed. Yep, this_cpu_* makes sense to me. Preemption is ok, since prev must always be a valid cpu id, thus we just get a little more _random_ from this pseudorandom implementation.