Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3643823ybl; Fri, 20 Dec 2019 12:59:07 -0800 (PST) X-Google-Smtp-Source: APXvYqytycsVvBPRYSchkZA5HP/X+BTK6Fu1UnCXTJJRSydX78ePzcnSBcgmsLQm1g8TzHHsTuRT X-Received: by 2002:a9d:5888:: with SMTP id x8mr16233212otg.361.1576875547020; Fri, 20 Dec 2019 12:59:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576875547; cv=none; d=google.com; s=arc-20160816; b=JICLF6RzJX1C31EUN7VjfNpgFKRKi0+AAVDKnjZZbeLFPE5/NRxXSnXGY6jxyT5dXY 4PQb5LeNBU1AblROnsYGGM/pTkXWFmKAxc64vOFL2pUWsJM7kxkU0XOEnDIX4U7EMd1E bZ8s4gRL0cs3Gt08sN69ScCBhPpxHzukORGhjcD587Hki8e/ekXXK0OYCt+mq/oB76kk cAyWXkyl1a5p/cDr8uzmaMY4GXkl9bulH8DSnbOUsoP+oEJZdyRSQmPTLIi4cN4kTAUr V8a1cCJ2WyOzWEzVfOx0nWqhlDVctBTJElvKC52hKxoZ8g6Wf/daZSxZ3zSq8g41gTHh 8utg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:in-reply-to:date:references:subject:cc:to:from; bh=iLkGyiEgHLGD/ZkSNf9OGiecdwRfvw4JVquoZOKc4Ww=; b=dshlv0i2RjwaUYG9HDdMv0bzgS86wHOgBUwiY48S+2WZysjiA7/mxTrI0h5colfE7P 1RI/5tEDeTi3VX9Nla3RRuSNUqQJkGGDFDaIaildZ15d4pd9d8I6MbtT/O26717nW2fN 2BHpqOAYD+x3CDm67I9ZAnTjEGfSOTBGenoxPrPsTxspuV+sP+Elmo/lS1lzyK3F4bqE K6yMSTOsuAI4GK3K8M18Dloo+YZUqr2vJn6MVeltkwi+lX+y63NfQ1jDRzo0VSgXGxwd sQzAWW1KbW6qd2WecCdxrtlaVRVv7lxCEpz0QaGeT/hiCOnzEkrMOuvT+Ms5U46BBmnq +Jiw== 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 p21si3256624otr.58.2019.12.20.12.58.54; Fri, 20 Dec 2019 12:59:07 -0800 (PST) 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 S1727491AbfLTU6S convert rfc822-to-8bit (ORCPT + 99 others); Fri, 20 Dec 2019 15:58:18 -0500 Received: from albireo.enyo.de ([37.24.231.21]:56130 "EHLO albireo.enyo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726525AbfLTU6S (ORCPT ); Fri, 20 Dec 2019 15:58:18 -0500 Received: from [172.17.203.2] (helo=deneb.enyo.de) by albireo.enyo.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) id 1iiPLh-000644-Fp; Fri, 20 Dec 2019 20:58:13 +0000 Received: from fw by deneb.enyo.de with local (Exim 4.92) (envelope-from ) id 1iiPKv-0003PZ-UB; Fri, 20 Dec 2019 21:57:25 +0100 From: Florian Weimer To: Mathieu Desnoyers Cc: Thomas Gleixner , linux-kernel , Peter Zijlstra , paulmck , Boqun Feng , "H. Peter Anvin" , Paul Turner , linux-api , stable , Dmitry Vyukov , Neel Natu Subject: Re: [PATCH for 5.5 1/2] rseq: Fix: Clarify rseq.h UAPI rseq_cs memory reclaim requirements References: <20191220201207.17389-1-mathieu.desnoyers@efficios.com> <87imman36g.fsf@mid.deneb.enyo.de> <173832695.14381.1576875253374.JavaMail.zimbra@efficios.com> Date: Fri, 20 Dec 2019 21:57:25 +0100 In-Reply-To: <173832695.14381.1576875253374.JavaMail.zimbra@efficios.com> (Mathieu Desnoyers's message of "Fri, 20 Dec 2019 15:54:13 -0500 (EST)") Message-ID: <875zian2a2.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Mathieu Desnoyers: > ----- On Dec 20, 2019, at 3:37 PM, Florian Weimer fw@deneb.enyo.de wrote: > >> * Mathieu Desnoyers: >> >>> diff --git a/include/uapi/linux/rseq.h b/include/uapi/linux/rseq.h >>> index 9a402fdb60e9..6f26b0b148a6 100644 >>> --- a/include/uapi/linux/rseq.h >>> +++ b/include/uapi/linux/rseq.h >>> @@ -100,7 +100,9 @@ struct rseq { >>> * instruction sequence block, as well as when the kernel detects that >>> * it is preempting or delivering a signal outside of the range >>> * targeted by the rseq_cs. Also needs to be set to NULL by user-space >>> - * before reclaiming memory that contains the targeted struct rseq_cs. >>> + * before reclaiming memory that contains the targeted struct rseq_cs >>> + * or reclaiming memory that contains the code refered to by the >>> + * start_ip and post_commit_offset fields of struct rseq_cs. >> >> Maybe mention that it's good practice to clear rseq_cs before >> returning from a function that contains a restartable sequence? > > Unfortunately, clearing it is not free. Considering that rseq is meant to > be used in very hot code paths, it would be preferable that applications > clear it in the very infrequent case where the rseq_cs or code will > vanish (e.g. dlclose or JIT reclaim), and not require it to be cleared > after each critical section. I am therefore reluctant to document the > behavior you describe as a "good practice" for rseq. You already have to write to rseq_cs before entering the critical section, right? Then you've already determined the address, and the cache line is already hot, so it really should be close to zero cost. I mean, you can still discard the advice, but you do so ad your own peril …