Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp687699ybi; Fri, 31 May 2019 07:30:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqz/8ctxlqKbvJrHgI/NRm/bI9vouDQLLvMIcEYSxFfEZztXACRzo/nky3mjgdjiYoaC7d4+ X-Received: by 2002:a65:528a:: with SMTP id y10mr9372005pgp.287.1559313052622; Fri, 31 May 2019 07:30:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559313052; cv=none; d=google.com; s=arc-20160816; b=Tx+2QukaPkrVctqG+B07en848KKQwxjYHyfbAHduZzmbowfacnxjhxNqoTfitUVavp D7JS5SZdBfhM/2a5/HJIu24hsif7pDPSMX//p8TqOlElQR6TyqpPOQ+b6oKxgydcVIzs 4/mvjapaheAF7O3Vkx4pckJJR8AArWQQL5V8ba67I51AP/hX7BDfCdCvH8vs90lF9aeA gAQxaIy31lGzj0grw+CpjCBjGZO6yt2yD7QDcyYj1FC/0Bmoa3apO6MtfKrlP0E7bHsM 1xTJvl2H03CTOwk8/qEv7eP0YWkNI/zN2Ws4jjdFCo/tMtoVlO67WVygE0eacpRwnldJ gxEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version; bh=HlHyvm9ihVjlMyZigoZKereWKKqkGXF0+Rxkr3nQk94=; b=Zv0fLNmMnbdpsYupoG9/J/9vhsj47ePzojSrSbd1gpQcTAgz+xLedZOy2o9zTrFEpU /Z+fTkEyNf6uep8nEsxhCCif8hLerZePIHD1XjDLZBYx86IXy7ScjH8Zxfkx2sapES7e tgcYimep31tZEyjphLg6rTPudXRFGhZ21KGKdgXiDRjc8SafN5WMsy+17CfKoUlPUgF+ wqcTigfrQlO8cQ3GI+6Q8A1WnIssrg+TyxcrqqvbwoulXWZgKn9nbYlod9BL7NtLHj9E 2nlpFccCxTpN6JOJFNnoWQX0gQTtqZ3ibVw7jMjSyQ+aNMYOjIQITSgnDLrympSwgXpP E51Q== 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 67si6140866pla.356.2019.05.31.07.30.35; Fri, 31 May 2019 07:30:52 -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 S1726687AbfEaO2i (ORCPT + 99 others); Fri, 31 May 2019 10:28:38 -0400 Received: from mx2.suse.de ([195.135.220.15]:59752 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726418AbfEaO2i (ORCPT ); Fri, 31 May 2019 10:28:38 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id EE5E1AF99; Fri, 31 May 2019 14:28:36 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 31 May 2019 16:28:36 +0200 From: Roman Penyaev To: Peter Zijlstra 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 In-Reply-To: <20190531125322.GY2606@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> Message-ID: X-Sender: rpenyaev@suse.de User-Agent: Roundcube Webmail Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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). -- Roman