Received: by 10.223.164.221 with SMTP id h29csp439399wrb; Thu, 26 Oct 2017 23:50:51 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Sdv6ECrAfyi3ME0FCYXWWTJZYOn9KYM6CKARdHl/Q3psBrrRslUozAefoVs079HmW9XcrJ X-Received: by 10.101.88.142 with SMTP id d14mr7021364pgu.36.1509087050917; Thu, 26 Oct 2017 23:50:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509087050; cv=none; d=google.com; s=arc-20160816; b=qHIFlIlixks+GGHJ8JFRzCOrqGaz35658YSBLRzbOIoky31JHO4CC1FXPJrFL6QhK1 rIY4pzkPuWHX55nnTN0XrKhnRwuDfhsxFKggCa3xAAGKghy5TR3uBPt0rXxJWjMI0fjF A/CuP7ZTCdoB73t+ZFt9+en4yzWTvNSTLwKepY18MWmgUlyrYzXDHfVq6qbATRX3ncR1 y6+mZrCnkw+myZds/cojcm2AkpGEG2zMlmKzU04G0wtt1G40CfGSke5N1mElHzesGFiX Yy6uByFhrXWZxGbPIFvYczLYS7AspPKsenNw8YvuH+vsILewueAUrmMd+WZSstjpagUa eMTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :dlp-reaction:dlp-version:dlp-product:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:arc-authentication-results; bh=4X6xfQNw7F8KrRnMWNuWN/L/J9wuwDEUAlWS9feU6A4=; b=scthLr8KWx69wRP1MASHv8TLJcOzYCEcdjyflmUaIbulUr35ZL5YjQSA/0LKL4fl61 i1x5V2m9HXqJeAW9U2BYN3srauEzal7tXmVT0zr9vITPno3MXLzYxCBSSliz19dLB1+N BLrKrD5de8+AVhr/rnsRjZes/YYBJAriPqEcaaTMSsoiRlf2y7bkoeDl4Zx4uY/RR8CJ 50rPXOuNr59Kd9bK/zSUMrl4F8KRumHHykdOxfALypjK8JlsBUYhlRyKxN96YL8slBAD GvtWjS+IVxALPlejXnAKClwdr+u3lio/wquuEMvHbu4PY2QLmifligtsA+mGm14vXSma hvGw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b126si4474695pgc.595.2017.10.26.23.50.37; Thu, 26 Oct 2017 23:50:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752089AbdJ0GuA convert rfc822-to-8bit (ORCPT + 99 others); Fri, 27 Oct 2017 02:50:00 -0400 Received: from mga06.intel.com ([134.134.136.31]:60675 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752054AbdJ0Gt6 (ORCPT ); Fri, 27 Oct 2017 02:49:58 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP; 26 Oct 2017 23:49:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,303,1505804400"; d="scan'208";a="1235952831" Received: from irsmsx152.ger.corp.intel.com ([163.33.192.66]) by fmsmga002.fm.intel.com with ESMTP; 26 Oct 2017 23:49:56 -0700 Received: from irsmsx102.ger.corp.intel.com ([169.254.2.180]) by IRSMSX152.ger.corp.intel.com ([169.254.6.87]) with mapi id 14.03.0319.002; Fri, 27 Oct 2017 07:49:55 +0100 From: "Reshetova, Elena" To: Peter Zijlstra CC: "linux-kernel@vger.kernel.org" , "gregkh@linuxfoundation.org" , "keescook@chromium.org" , "tglx@linutronix.de" , "mingo@redhat.com" , "ishkamiel@gmail.com" Subject: RE: [PATCH] refcount: provide same memory ordering guarantees as in atomic_t Thread-Topic: [PATCH] refcount: provide same memory ordering guarantees as in atomic_t Thread-Index: AQHTS+92qOdaqfxtzUSi29Fjx7+W86LxWH8AgAXrypA= Date: Fri, 27 Oct 2017 06:49:55 +0000 Message-ID: <2236FBA76BA1254E88B949DDB74E612B802B6A2E@IRSMSX102.ger.corp.intel.com> References: <1508756984-18980-1-git-send-email-elena.reshetova@intel.com> <20171023131224.GC3165@worktop.lehotels.local> In-Reply-To: <20171023131224.GC3165@worktop.lehotels.local> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMzBhNjYzOWQtMjE2Ny00ZTdiLTk1Y2UtYmY5ZjU3ZDljNjdhIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJ1Ymp1Y0huOVRFWHc2TENxVU1PMm9vY1wvYjV3OEJkMVp3ZHd2d2VvUU1tY2JSQlwvd0VqXC9HUXFcL3lUeWVXOXBUTyJ9 x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Mon, Oct 23, 2017 at 02:09:44PM +0300, Elena Reshetova wrote: > > Currently arch. independent implementation of refcount_t in > > lib/refcount.c provides weak memory ordering guarantees > > compare to its analog atomic_t implementations. > > While it should not be a problem for most of the actual > > cases of refcounters, it is more understandable for everyone > > (and more error-prone for future users) to provide exactly > > same memory ordering guarantees as atomics. > > > > If speed is of a concern, then either more efficient arch. > > dependent refcount_t implementation should be used or if there > > are enough users in the future we might need to provide both > > strict and relaxed refcount_t APIs. > > > > Suggested-by: Kees Cook > > NAK Could we possibly have a bit more elaborate discussion on this? Or alternatively, what then should be the correct way for a certain variable (that behaves like a standard refcounter) to check if the relaxed memory ordering is ok? This is what Thomas was asking me to do for core kernel conversions and this is what I don't know how to do correctly. Also, I got exactly the same question from xfs maintainer, so if we provide an API that we hope will be used correctly in the future, we should have a way for people to verify it. Maybe it is just me, but I would think that having a way to verify that your code is ok with this refcounter-specific relaxed memory ordering applies to any memory ordering requirements, refcounters are just a subset with certain properties, so is then the full answer is to figure out how to verify any memory ordering requirement of your code? We can also document this logic in more docs or even maybe try to create a better documentation for current memory ordering bits since it is not the most easiest read at the moment. Otherwise this might be just bad enough reason for many people to avoid refcount_t type if it is just easier to tell "let's take just old atomic, we knew it somehow worked before".... Best Regards, Elena. From 1582054140498640955@xxx Mon Oct 23 13:13:20 +0000 2017 X-GM-THRID: 1582046402032606032 X-Gmail-Labels: Inbox,Category Forums