Received: by 10.213.65.68 with SMTP id h4csp125760imn; Tue, 27 Mar 2018 23:45:40 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+hWSKhVieFoy7YRe5hBKie8yGbP3uxOgg9z+On43ZfMXFEW0TFng5svqP+q/4Gx6WB7Oh9 X-Received: by 2002:a17:902:7102:: with SMTP id a2-v6mr2474972pll.87.1522219540398; Tue, 27 Mar 2018 23:45:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522219540; cv=none; d=google.com; s=arc-20160816; b=zpkIQ0SN6B5trMrbi+KwdsLSZIt/HzYUjxayJRTkDbkAwYQ3Wxk5jvAHcK/wO5Elnj Fa0e3NhjtMFh0SWgDJ6GAEsYyuaUmBYmPn4yYxRQnPqywsLzplK2k3ewCSg/6h+yzGei vfknk9Ik7jP/MpTJ24XRGcyJRBKMrQJx+Std/v349x5W5bZOVXNc10qaKFkCOspuEsrP g88/lmZqOECfeIrsb10c95Z7R2ZmGlx83wAXRs1dvhfFygPvoOsG2ktoA7E25bGhN9cR +qxJo5QttTGJQeq7SPtzqZHFU/RLmy2lvPyoQAYZP7JRubqqQZHu1p6Qi7ajEG1jgUJ7 rfGw== 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:arc-authentication-results; bh=Ox9GKe6+cYgjrEf7A4f8xXuGwDkwsrLylHcHsCgS7xg=; b=AQP1lc3FygRcRabBTIU4J26K30WhkECuX1VG865UWPnxW65cD5zsqp0zkZZM6fSBkP L43JVC4HZ7457wYePowhen4VjBSvr1W4QRF+OsOriTXmWKAEGrQTSuEFuv89COiSTAzj 2uiodBJBYATjhgdUoJlorBKZ1nprgNlqNLCvGZ6G7EAptMpDCm5MRrUv9BZSLqMe5ijw +qpkpxKWag1Rb1E0YoEpECejcvmOcZXRU3idYyI9U/q/idUwBWbGVSqfjHUzBN/P2VZT qDa10XcXp7cl0vmJSkPy8+OpHTM8EvGCcvz0JaidRINsbyBgsFX4g9pKTHSj9131cXiQ mKpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=X0YBJ1gM; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 13-v6si2804641plb.515.2018.03.27.23.45.25; Tue, 27 Mar 2018 23:45:40 -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=pass header.i=@gmail.com header.s=20161025 header.b=X0YBJ1gM; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752663AbeC1GoD (ORCPT + 99 others); Wed, 28 Mar 2018 02:44:03 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:40603 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752462AbeC1GoB (ORCPT ); Wed, 28 Mar 2018 02:44:01 -0400 Received: by mail-wm0-f66.google.com with SMTP id x4so2936683wmh.5; Tue, 27 Mar 2018 23:44:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Ox9GKe6+cYgjrEf7A4f8xXuGwDkwsrLylHcHsCgS7xg=; b=X0YBJ1gM4ZG8YKv+xZAV4swJ07Z7tXFcy83gee9qjJSxnwWnOn/alJRncdcNG48A4t xfQHrduz++a4kGD0TXfad/cK0RPV9HWVv6T01yG2wyY7+lq/QCUZ+ibq+kgoVhlYqOXR bEVnnw3EqmVWb3HzkBpiQUPmCQX+WGnQfi99ZSzXEwYZ5WCriKod5dAiGyvUoMCWv3Kc IfnT68du2MWIM/QjVLYtVL1zw/wAS30ZCoSDRxcwDMx8lfNZn8SDIUB2CzEFN2YtK5so Gts3XWMiFTMyhL3Ptzj0aoIFL8F2hA57xxH8BDbKArI/26MIBHR983YMs2XeFLwe9f/c fiSw== 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:user-agent; bh=Ox9GKe6+cYgjrEf7A4f8xXuGwDkwsrLylHcHsCgS7xg=; b=adgIqq5DtDSO0/oQhDmNiOf7mEhX+ySWZWSXPz2Vjr0tynUgiaUFjWnK2/YrXuc5kf ktQBH9dXsTBO0ovRLMYV56Lu2fe81j1+cLMo2qBIW+1jGNieJQJA2mm+CWvyIFF/xRM0 ViCm9iqkTfFg0ITRAlU1jrFeWzflmsi7/HvULgLP4QloxXWZKtLa7+EsvNPNJJUz5QYZ DJ1n+8lpbBC4A6SNE7uc68GLCYFIuoDWi8LyBA59ydFvRxGwgk2p0d3Ow4xaub+fINHB D9qONUYB5k/vdTOoLpYKiwrwdxxG1AuG8YkPDqeqnftNPfGKZTJJ5broWnd/vwN7RXOk +a9A== X-Gm-Message-State: AElRT7Gq1X8smo/7Ij6CsmBRTmEd4gmsVsQH4o7x6H24k0VENS/g7K5j A2n+ikFKVRkxZS58U0YYgGI= X-Received: by 10.80.235.72 with SMTP id z8mr2133989edp.170.1522219439550; Tue, 27 Mar 2018 23:43:59 -0700 (PDT) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id r6sm1946756edi.21.2018.03.27.23.43.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Mar 2018 23:43:58 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id C6DAF211ED; Wed, 28 Mar 2018 02:43:54 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Wed, 28 Mar 2018 02:43:54 -0400 X-ME-Sender: Received: from localhost (unknown [45.32.128.109]) by mail.messagingengine.com (Postfix) with ESMTPA id 13F2A10258; Wed, 28 Mar 2018 02:43:54 -0400 (EDT) Date: Wed, 28 Mar 2018 14:47:54 +0800 From: Boqun Feng To: Mathieu Desnoyers Cc: Peter Zijlstra , "Paul E . McKenney" , Andy Lutomirski , Dave Watson , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Paul Turner , Andrew Morton , Russell King , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Andrew Hunter , Andi Kleen , Chris Lameter , Ben Maurer , Steven Rostedt , Josh Triplett , Linus Torvalds , Catalin Marinas , Will Deacon , Michael Kerrisk , Alexander Viro Subject: Re: [RFC PATCH for 4.17 02/21] rseq: Introduce restartable sequences system call (v12) Message-ID: <20180328064703.56hsuicmikejg7np@tardis> References: <20180327160542.28457-1-mathieu.desnoyers@efficios.com> <20180327160542.28457-3-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="yzsuj5wf7xcogpl6" Content-Disposition: inline In-Reply-To: <20180327160542.28457-3-mathieu.desnoyers@efficios.com> User-Agent: NeoMutt/20171215 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --yzsuj5wf7xcogpl6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Mar 27, 2018 at 12:05:23PM -0400, Mathieu Desnoyers wrote: [...] > Changes since v11: >=20 > - Replace task struct rseq_preempt, rseq_signal, and rseq_migrate > bool by u32 rseq_event_mask. [...] > @@ -979,6 +980,17 @@ struct task_struct { > unsigned long numa_pages_migrated; > #endif /* CONFIG_NUMA_BALANCING */ > =20 > +#ifdef CONFIG_RSEQ > + struct rseq __user *rseq; > + u32 rseq_len; > + u32 rseq_sig; > + /* > + * RmW on rseq_event_mask must be performed atomically > + * with respect to preemption. > + */ > + unsigned long rseq_event_mask; s/unsigned long/u32 > +#endif > + > struct tlbflush_unmap_batch tlb_ubc; > =20 > struct rcu_head rcu; > @@ -1688,4 +1700,110 @@ extern long sched_getaffinity(pid_t pid, struct c= pumask *mask); > #define TASK_SIZE_OF(tsk) TASK_SIZE > #endif > =20 [...] > + > +static int rseq_ip_fixup(struct pt_regs *regs) > +{ > + unsigned long ip =3D instruction_pointer(regs), start_ip =3D 0, > + post_commit_offset =3D 0, abort_ip =3D 0; > + struct task_struct *t =3D current; > + uint32_t cs_flags =3D 0; > + bool in_rseq_cs =3D false; This seems unnecessary? Because.. > + int ret; > + > + ret =3D rseq_get_rseq_cs(t, &start_ip, &post_commit_offset, &abort_ip, > + &cs_flags); > + if (ret) > + return ret; > + > + /* > + * Handle potentially not being within a critical section. > + * Unsigned comparison will be true when > + * ip >=3D start_ip, and when ip < start_ip + post_commit_offset. > + */ > + if (ip - start_ip < post_commit_offset) > + in_rseq_cs =3D true; > + > + /* > + * If not nested over a rseq critical section, restart is > + * useless. Clear the rseq_cs pointer and return. > + */ > + if (!in_rseq_cs) > + return clear_rseq_cs(t); we can write if (ip - start_ip >=3D post_commit_offset) return clear_rseq_cs(t); Regards, Boqun > + ret =3D rseq_need_restart(t, cs_flags); > + if (ret <=3D 0) > + return ret; > + ret =3D clear_rseq_cs(t); > + if (ret) > + return ret; > + trace_rseq_ip_fixup(ip, start_ip, post_commit_offset, abort_ip); > + instruction_pointer_set(regs, (unsigned long)abort_ip); > + return 0; > +} > + [...] --yzsuj5wf7xcogpl6 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEj5IosQTPz8XU1wRHSXnow7UH+rgFAlq7OpYACgkQSXnow7UH +rjwhQf+LeKpKOoiYs2E75v4BONhGBr6S9icQvXV25bXj3nlHUJSOW9yHPtN3wjq GwR0eZQkCfKm5ir9BDyRe1L5nKYDWVz7qdj6IDN67yPr6fnAFPw1SNIM8RsOBvn2 d5bLKbPAEJIvv0JWH7VQedq4SlQYfCKPrv0ue45QReE1FsxlDXPt1Aq3El4BUMaw yXEA4xMijOFqk8WOspEjgRkHn/k9jOCKpkVg/dCAu9OZ6Ivqsr4GKvaSpoo9RMfF EqR0/az/GkdJNEh0QlApYNNhBxB+dHd49bMN1K4ql2G7j1St+g6Vdb/3i6KM9PWJ alGOemjl4GXknHu6RE4U9ODYpGUBtQ== =e8tt -----END PGP SIGNATURE----- --yzsuj5wf7xcogpl6--