Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3602593pxt; Tue, 10 Aug 2021 07:17:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBST8TVbThCkAGIzyr1vbhxoiX5FicLvrGv+AS5VbbmPoobklyneGGry168OfgPppm3O+z X-Received: by 2002:a17:906:f28f:: with SMTP id gu15mr28244770ejb.7.1628605040629; Tue, 10 Aug 2021 07:17:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628605040; cv=none; d=google.com; s=arc-20160816; b=MSMaBx6awop7Hz8jMWugesc6e/KBOsZSh+BfKtyb7yD5Jdof8lXOsxkl9aZ0PsHqnk W9aVX+OEBGbbnvd0YYQgONNkXLhJQRC037zHTd3/zZ/Mt2Eb1OIrHwPjLLU1bB4ji7us /rKbA331FrNGh7GPXo7Tw6OHOqK3e3RLlyuVzpzZi4bIC/GNgdXixZUcZuAWaB1YqTV6 8UOiWr9dKcZ0GEnPze/jutUbCPyJsLVuOCKp5cWl8lScWesxzwhYgT0A1AJiM5RsGZX2 AnApFf4NlnimOEdfarZ5jMagkaoiKZEaHpY2TrAABvXOZa2OZnt6VbPmTkClMAC7ADw9 E/Xg== 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=CDRkvf+rJoAcxbVNpNU7zFOiE0Wsf0lTz3fYz3qZAV0=; b=ZRpQQu2UtwCgMXPiYAK+OW7VfeSt7TDOgBBS1P5ZUDtupNiD7FIP6CXaj+jPC3eHzf ekP3HLWC7vE7eQ/1LBCUMVZCu26v57OEitkuxM4j5kRXIoogErGykmuZ4R/urV3U4e0s RQm5WYTRlIoBSYVuk8hEqvDkYTwZt/5h3XWN+NJosAtOqWb0ebG+ovYwNyF3wn1vAgje K88u0IQeYWgIo2TLCRiT7xopQshPjzJTF8aADX7YCV4xyBSM5Mn0sCh9KM1hmWL4QorD UwcMtX6Tle+q97/pbgk28jAO16e46pti86KnILrdiOmoXfpDbBA0ARDHLTwHshnPi1TR iPMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JrVsvoAX; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a4si19898371ejx.13.2021.08.10.07.16.56; Tue, 10 Aug 2021 07:17:20 -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=@gmail.com header.s=20161025 header.b=JrVsvoAX; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240827AbhHJMtv (ORCPT + 99 others); Tue, 10 Aug 2021 08:49:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240821AbhHJMtu (ORCPT ); Tue, 10 Aug 2021 08:49:50 -0400 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8297CC0613D3; Tue, 10 Aug 2021 05:49:28 -0700 (PDT) Received: by mail-il1-x131.google.com with SMTP id u7so285465ilk.7; Tue, 10 Aug 2021 05:49:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=CDRkvf+rJoAcxbVNpNU7zFOiE0Wsf0lTz3fYz3qZAV0=; b=JrVsvoAXeKzYVXrJv/0UdM5aFUuV2yF8ZiUCKaZxxysdmY0fSnreZ++Brhu+X8VTUF a3savyhbXE7nqTLZkMEQItv2E63MXOyhXmm/LYrAfPCrh+wn6pVLUspcNQyupi9BrWHM pj9SBMhT76vnNKeNItpuvst5j7q+/6Df634FUqWfC3Niv4utdPO5wk4xpEfM3Dve28am rmZMAaxFSmGdY7TEd/JMF8Lou2qeewFinS0ZRUvGDkJUcsSXtLFkblAyGojvPjcWXuCn 4/dPIIWRaFez41qSEIc0p3aDuVXns8E6x9iufCp3Jlk5UaqlWX01kPC6tsLieWZEChnN vOwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=CDRkvf+rJoAcxbVNpNU7zFOiE0Wsf0lTz3fYz3qZAV0=; b=fonc2NtynUs11UFr3UzcmR7+zyk83mfqvVwncct4R5Vh43BKw1W4LeNH55ZMrMSRyB O7ynnCv0dpcLXlqSDwUqx51U7VVYohm+0Ys6Td6teIBZA5lXUS4mFYv0W1CDLQx75tD/ KfSu011yOpFQHU8bfYTJo1oobum0u3soh2A2YYXIq3+MgQuVYr0Tj/fL5tGczzakHRS7 mJdGB7rZHwAIU1I6m9on+9NFFz9suePzwL1Zteds2fIBoOYuK2Yepsio097LzWnwyGQb 0us0zeUFsgK430rHNfzt6Kqt0MHy2jnzET/zE42/HHTeLAadk6/xCZnc8LJJoleGM7/b 51+g== X-Gm-Message-State: AOAM530o6vv1N5ZWZenY6MhSxVIcl+ptfY2hVnQTK+jM0uZ23PLAlXxn nyars4nhL4frdH+YZ2TaT9g= X-Received: by 2002:a92:d987:: with SMTP id r7mr21377iln.303.1628599767987; Tue, 10 Aug 2021 05:49:27 -0700 (PDT) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id q8sm5256775ilg.6.2021.08.10.05.49.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Aug 2021 05:49:27 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailauth.nyi.internal (Postfix) with ESMTP id 0541827C0054; Tue, 10 Aug 2021 08:49:25 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 10 Aug 2021 08:49:26 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrjeelgdehjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepuehoqhhunhcu hfgvnhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrdgtohhmqeenucggtffrrghtth gvrhhnpedvleeigedugfegveejhfejveeuveeiteejieekvdfgjeefudehfefhgfegvdeg jeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegsoh hquhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdeiledvgeehtdeigedq udejjeekheehhedvqdgsohhquhhnrdhfvghngheppehgmhgrihhlrdgtohhmsehfihigmh gvrdhnrghmvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 10 Aug 2021 08:49:21 -0400 (EDT) Date: Tue, 10 Aug 2021 20:49:14 +0800 From: Boqun Feng To: Valentin Schneider Cc: Mike Galbraith , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, rcu@vger.kernel.org, linux-rt-users@vger.kernel.org, Catalin Marinas , Will Deacon , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , Steven Rostedt , Daniel Bristot de Oliveira , Sebastian Andrzej Siewior , "Paul E. McKenney" , Frederic Weisbecker , Josh Triplett , Mathieu Desnoyers , Davidlohr Bueso , Lai Jiangshan , Joel Fernandes , Anshuman Khandual , Vincenzo Frascino , Steven Price , Ard Biesheuvel Subject: Re: [PATCH v2 2/4] sched: Introduce is_pcpu_safe() Message-ID: References: <20210807005807.1083943-1-valentin.schneider@arm.com> <20210807005807.1083943-3-valentin.schneider@arm.com> <800ff941e3ec86ea1397cddf8ecea3d4a17c55dc.camel@gmx.de> <87a6lrap5z.mognet@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87a6lrap5z.mognet@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Aug 08, 2021 at 05:15:20PM +0100, Valentin Schneider wrote: > On 07/08/21 03:42, Mike Galbraith wrote: > > On Sat, 2021-08-07 at 01:58 +0100, Valentin Schneider wrote: > >> > >> +static inline bool is_pcpu_safe(void) > > > > Nit: seems odd to avoid spelling it out to save two characters, percpu > > is word like, rolls off the ole tongue better than p-c-p-u. > > > > -Mike > > True. A quick grep says both versions are used, though "percpu" wins by > about a factor of 2. I'll tweak that for a v3. I wonder why is_percpu_safe() is the correct name. The safety of accesses to percpu variables means two things to me: a) The thread cannot migrate to other CPU in the middle of accessing a percpu variable, in other words, the following cannot happen: { percpu variable X is 0 on CPU 0 and 2 on CPU 1 CPU 0 CPU 1 ======== ========= __this_cpu_inc(X); tmp = X; // tmp is 0 // continue __this_cpu_inc(X); X = tmp + 1; // CPU 0 miss this // increment (this // may be OK), and // CPU 1's X got // corrupted. b) The accesses to a percpu variable are exclusive, i.e. no interrupt or preemption can happen in the middle of accessing, in other words, the following cannot happen: { percpu variable X is 0 on CPU 0 } CPU 0 ======== __this_cpu_inc(X); tmp = X; // tmp is 0 this_cpu_inc(X); // X is 1 afterwards. X = tmp + 1; // X is 1, and we have a race condition. And the is_p{er}cpu_safe() only detects the first, and it doesn't mean totally safe for percpu accesses. Maybe we can implement a migratable()? Although not sure it's a English word. Regards, Boqun