Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp861977ybi; Fri, 31 May 2019 09:56:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqzsSm/0Cn1fprWegFFQw2coIRcxufA3drrE/QmYYR0Qu/3inQ8jC+GysPiq1tDDxFtoJSfB X-Received: by 2002:aa7:940e:: with SMTP id x14mr8807021pfo.183.1559321813027; Fri, 31 May 2019 09:56:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559321813; cv=none; d=google.com; s=arc-20160816; b=F62fB+Tfb+eazucHifwSdOPpfwMN+VBlK+sQdkyXyDfgbpdi+IhdR4RPVVZG2xKknB n2NPGQSC7IT5EAIA8LVoae+fwf+xQY5+p99uh8IYDTKHwUiYRPtXDScSw78dUsaZi6EX RVKk9bWzYi375ezX82k4S3fUqVCS8HPiTnB5TvtTVATB7u6kCPi6nOA/27EzaJXXM5zW A7mgluFbbEFj0neKwAgkBAQaLdEwgIRxSriNE26ZYsP8d78NHdldjCgohIJ1HjFfL2K/ UsnwEvexOxRqiV/Mdfp9OSjX7ru3IcsOAtfFwbJeLFOwpwHcFsnBrjBHLxmMD2FwdD0z dEOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=EwwHRpwcuNoUVD2uOJfJisf1Ruiz96l2Tq7xkdtjsco=; b=eTvVZqE1aKLjZT8CZbtRAXgxTm35pbA84xcf4g8CrtBKMZmkYovc7tj8M/79+7DXtp JdllbmNAplW2XQmITsjVHD+3xdTpA7oUGVJnU+8/IED0i91Qjz5GZbbFSX1qnxdkVTVM JezQA6x9HaLxstkdI6znb+dzSPIPMRoiXAwkLzbLLg3UikmINJb9nfuTN0HCCLPOCMzK uHGY61ppMHI4AnyMUX6w0YclLdFr/KeYB9v74v8Oa0QI7ZAQsxwP7qPFs8ZyXVHH2ShA 1YZiOuJ/x8pORBIyZlTNpDHoXDcBlEv9EQEWHbgn/RBTbC7CAX78YJtbjEEXoyiqR7wB DDnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=er11kocx; 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 c8si6240966pjs.87.2019.05.31.09.56.34; Fri, 31 May 2019 09:56:53 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=er11kocx; 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 S1727099AbfEaQxy (ORCPT + 99 others); Fri, 31 May 2019 12:53:54 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:51738 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726518AbfEaQxy (ORCPT ); Fri, 31 May 2019 12:53:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=EwwHRpwcuNoUVD2uOJfJisf1Ruiz96l2Tq7xkdtjsco=; b=er11kocxvUKsBah4spbwucg2T gmxEUmaH7MI+j1gwH5cpm2dHtkL47LA+NGOXt1j0glcDnqm2EMqgxfM5ynMP8pT6lBKivIIIf4l1/ 0PLb1QaiUM7lnqKih9OfjvumXD8F+lvCYms3/Bu6miiB7cJ4sLBK0ahPeLYo8VWC4UOQE04Rm67wK YARlict22WmnbqQ2Fj83Zjrj5TgggM5Fdghr5LvzELbTSElogzwoPyaaZu6YlH65lfXKVT7Fhg+Ih NLJx4Hytm9n4XDR87Ah6BfLTZyieb6N3AcgLwxpaLTEB9OJ7nOa7WqrGxbgNvPySNTLQg0VrZgdYL 6s665T4ow==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hWkmt-0004Az-DM; Fri, 31 May 2019 16:53:51 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id DCB70201CF1CB; Fri, 31 May 2019 18:53:49 +0200 (CEST) Date: Fri, 31 May 2019 18:53:49 +0200 From: Peter Zijlstra To: Roman Penyaev Cc: azat@libevent.org, akpm@linux-foundation.org, viro@zeniv.linux.org.uk, torvalds@linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 06/13] epoll: introduce helpers for adding/removing events to uring Message-ID: <20190531165349.GF2606@hirez.programming.kicks-ass.net> References: <20190516085810.31077-1-rpenyaev@suse.de> <20190516085810.31077-7-rpenyaev@suse.de> <20190531095607.GC17637@hirez.programming.kicks-ass.net> <274e29d102133f3be1f309c66cb0af36@suse.de> <20190531125322.GY2606@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 31, 2019 at 04:28:36PM +0200, Roman Penyaev wrote: > On 2019-05-31 14:53, Peter Zijlstra wrote: > > On Fri, May 31, 2019 at 01:15:21PM +0200, Roman Penyaev wrote: > > > On 2019-05-31 11:56, Peter Zijlstra wrote: > > > > On Thu, May 16, 2019 at 10:58:03AM +0200, Roman Penyaev wrote: > > > > > > > + i = __atomic_fetch_add(&ep->user_header->tail, 1, > > > > > + __ATOMIC_ACQUIRE); > > > > > > > > afaict __atomic_fetch_add() does not exist. > > > > > > That is gcc extension. I did not find any API just to increment > > > the variable atomically without using/casting to atomic. What > > > is a proper way to achieve that? > > > > That's C11 atomics, and those shall not be used in the kernel. For one > > they're not available in the minimally required GCC version (4.6). > > > > The proper and only way is to use atomic_t, but also you cannot share > > atomic_t with userspace. > > Yes, that what I tried to avoid choosing c11 extension. > > > > > The normal way of doing something like this is to have a kernel private > > atomic_t and copy the value out to userspace using smp_store_release(). > > Since this path is lockless unfortunately that won't work. So seems > the only way is to do one more cmpxchg (sigh) or give up and take a > look (sad sigh). Of course it works; most of the extant buffers already have a shadow tail and do the update to userspace with a store-release.