Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3319468pxk; Mon, 28 Sep 2020 14:18:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxupZmcdnYZGuoxYkIfgc3+CH7Z5C7OvcDqMDdz1BMvJCxitz3XW1xTlCTX1KpTBJs89WP7 X-Received: by 2002:a17:906:8695:: with SMTP id g21mr663053ejx.504.1601327916286; Mon, 28 Sep 2020 14:18:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601327916; cv=none; d=google.com; s=arc-20160816; b=Hpb28YZpyuLjFoePY5//AeEQhRDsWn6+9rrOpoX2aa5aEjFjvqcrLaoYfKYGKOdN0S /Q+Q7olYKu2dGVkKt3CQnwhRZEjKMcizKsMOep6g2oLunc0wkVfAxvtuPdTiVUdJMTgM pXNXeImAfMN6FicixsEt+QGpnUy8N4ZSQokNGVnUn84gnGQ6YqZP/oYZChzf/oUtbwKo hit72Y8G7sQVV9UrIevDms1hUJTaPq/uIOSM3Nob4QCSHHJm6rsHFePXW2HFI34OjYt0 6da28jq2nlpMEEDPJrGhXBKTCIzgFg9/rpJ1bfGlp0sYPjJ79sFnYmlYFuBmF0Zqrhg9 fv1w== 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=TsieN2AyZd+fHurZfoVnAsK/371QDPaE9PSaaOsF10M=; b=TJ1K5XV3vb3+LKGWUCMwKlZJHSXuYq08lUNAlq450TGXJh0X/BYmZMCfKtzgZpZNUa YK63To4Z0vwYECBdfCCfNLXddTF+lekOSqKo/6EP9YYFJRkdj113P6dzdFYAc+1l3wuV Q4vVBFUNLuBgMCzPz05m3qn3e5tn6k8O+8YSZiWt2B0wYTHo9uocUCKmxEzZC1+F/U57 9oNOF2S19EjVTxf/VvVuocAiA+JdaOEsUQ3dog6oOfBTGV04zJyfufviQW8vTDsi0GEv vuhD/1RnJzKeiEz5vmYySavgfNgv7i8jZjg1k56Zt117ZNKp4Zf2Q842NVR6iHsxlnkl IyLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b="E/E+O1Kd"; 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 b2si1592537edf.162.2020.09.28.14.18.13; Mon, 28 Sep 2020 14:18:36 -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=@joelfernandes.org header.s=google header.b="E/E+O1Kd"; 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 S1726920AbgI1VRL (ORCPT + 99 others); Mon, 28 Sep 2020 17:17:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726565AbgI1VRL (ORCPT ); Mon, 28 Sep 2020 17:17:11 -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 2BE5EC061755 for ; Mon, 28 Sep 2020 14:17:11 -0700 (PDT) Received: by mail-qt1-x844.google.com with SMTP id o21so1974852qtp.2 for ; Mon, 28 Sep 2020 14:17:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=TsieN2AyZd+fHurZfoVnAsK/371QDPaE9PSaaOsF10M=; b=E/E+O1Kdz8L/LgV+e3noNHmCUepRX8tYRdZmhvH1oqH1ALQLGP9YZ/dETKdHtGk05j wpvbZI+tcv1EpJog3kH/xRzfufYZLAbq6RvYEyNhs/6/SDQpmj5TkCNNlF085WCvLpfS QF38VkMXId3KqzhLsBF8KxCGWUfAw8jaSZCwY= 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=TsieN2AyZd+fHurZfoVnAsK/371QDPaE9PSaaOsF10M=; b=RSCyNWu/Uv+fDexjGoCT9iDLFHiy+cPqOuwtNnA5tpzRISjiyXRJCpVwdAaLtCUI6j vbQwyx8auxdshJm51KRePDE5q4YAXdblKmyfnMbKr5CHxoovfJqSCk8T2h9KjUYJ/xKP W6m/dRK3JeNHGb3GMmyctTn0GdCyWkLvQBKso58380owCGcz1BwTV7qLd6w3flpRRtTj FKytKXY1c6sA3r9FHk8ePGsrY4pGEwMbt/q0coLpNsMhqU/3uh6Ix+cA4wIlzaAvi2ZV RcqRUOB6kjdiAbNQu9GQPidfi5P2MWvA4UGsJ5rtitsy7LX+MGUfoFH0+an0Km6nBnkh j0PA== X-Gm-Message-State: AOAM530TLLVWQCV+cZxGYQNPYXiU9zue7HsHWH4OHSJ53Iox5sDo3hB7 PlzOyGkMrupdHESrb6+0E0DXOQ== X-Received: by 2002:aed:25d1:: with SMTP id y17mr11236qtc.375.1601327830218; Mon, 28 Sep 2020 14:17:10 -0700 (PDT) Received: from localhost ([2620:15c:6:12:cad3:ffff:feb3:bd59]) by smtp.gmail.com with ESMTPSA id x26sm2483053qtr.78.2020.09.28.14.17.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 14:17:09 -0700 (PDT) Date: Mon, 28 Sep 2020 17:17:09 -0400 From: Joel Fernandes To: Kees Cook Cc: Shuah Khan , corbet@lwn.net, gregkh@linuxfoundation.org, shuah@kernel.org, rafael@kernel.org, johannes@sipsolutions.net, lenb@kernel.org, james.morse@arm.com, tony.luck@intel.com, bp@alien8.de, arve@android.com, tkjos@android.com, maco@android.com, christian@brauner.io, hridya@google.com, surenb@google.com, minyard@acm.org, arnd@arndb.de, mchehab@kernel.org, rric@kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-acpi@vger.kernel.org, devel@driverdev.osuosl.org, openipmi-developer@lists.sourceforge.net, linux-edac@vger.kernel.org Subject: Re: [PATCH 00/11] Introduce Simple atomic and non-atomic counters Message-ID: <20200928211709.GA2641213@google.com> References: <20200927233526.GA500818@google.com> <202009281331.444F36A7B@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202009281331.444F36A7B@keescook> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 28, 2020 at 01:34:31PM -0700, Kees Cook wrote: > On Sun, Sep 27, 2020 at 07:35:26PM -0400, Joel Fernandes wrote: > > On Fri, Sep 25, 2020 at 05:47:14PM -0600, Shuah Khan wrote: > > > This patch series is a result of discussion at the refcount_t BOF > > > the Linux Plumbers Conference. In this discussion, we identified > > > a need for looking closely and investigating atomic_t usages in > > > the kernel when it is used strictly as a counter without it > > > controlling object lifetimes and state changes. > > > > > > There are a number of atomic_t usages in the kernel where atomic_t api > > > is used strictly for counting and not for managing object lifetime. In > > > some cases, atomic_t might not even be needed. > > > > > > The purpose of these counters is twofold: 1. clearly differentiate > > > atomic_t counters from atomic_t usages that guard object lifetimes, > > > hence prone to overflow and underflow errors. It allows tools that scan > > > for underflow and overflow on atomic_t usages to detect overflow and > > > underflows to scan just the cases that are prone to errors. 2. provides > > > non-atomic counters for cases where atomic isn't necessary. > > > > Nice series :) > > > > It appears there is no user of counter_simple in this series other than the > > selftest. Would you be planning to add any conversions in the series itself, > > for illustration of use? Sorry if I missed a usage. > > > > Also how do we guard against atomicity of counter_simple RMW operations? Is > > the implication that it should be guarded using other synchronization to > > prevent lost-update problem? > > > > Some more comments: > > > > 1. atomic RMW operations that have a return value are fully ordered. Would > > you be adding support to counter_simple for such ordering as well, for > > consistency? > > No -- there is no atomicity guarantee for counter_simple. I would prefer > counter_simple not exist at all, specifically for this reason. Yeah I am ok with it not existing, especially also as there are no examples of its conversion/usage in the series. > > 2. I felt counter_atomic and counter_atomic64 would be nice equivalents to > > the atomic and atomic64 naming currently used (i.e. dropping the '32'). > > However that is just my opinion and I am ok with either naming. > > I had asked that they be size-named to avoid any confusion (i.e. we're > making a new API). Works for me. Cheers, - Joel