Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4400094ybv; Tue, 25 Feb 2020 19:26:55 -0800 (PST) X-Google-Smtp-Source: APXvYqyYLaPAE5RAmdgy7BAwFfzl8xhh7J3W9R4GAUSKsY4VIvreUW+6TZ08Jv+sh8KSLkj4Pqz4 X-Received: by 2002:a9d:170a:: with SMTP id i10mr1363075ota.284.1582687614984; Tue, 25 Feb 2020 19:26:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582687614; cv=none; d=google.com; s=arc-20160816; b=AN3paAt+KcsyiM4NBNiHnWKuVKgtQ7wBqBsROUKRWMRu9ibYdtPWXgOdySSpZP3CV9 JzrsySH4fewL+L0NcwE3PVe814lzxtmn2faInkWsdmJe33Hoy9cPu4SPwuvr9a3voTnq 85rGDRET6VjgtcxTgxFSdNYirsdyk2htEltd+HGFBY+z/SvPKBqyG/Z39+DrZS0/B8dx z+6ef9EoJ+pEBjuBJiS574iBPpsmukAA7F+xPTXoh3bYIN989gj3ea2Uy7NA73XKdxSF LKmGcwXSEsUF04NtsrVHxW8j32a9XJs55LxnqJM9Y8wyY2WOjgNwC94WY+xme0qBVbY5 6qKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=IOzAwCx4zkKExWVM/1JeparZOmVnpclobVkhjd9ROHU=; b=tkP/WWzyeFCZcdg/M38RqFkd8gN0IiX3asQrX8FgKynhAgJpwX+5IvREA/otj+peNd s4LUjq9MEcGSVjj/a+wl8OWn3kBdHIiLdAWCrsIjYKld4Djf/xcNIkgEeh1B0ke3uz9r UGqzFgq2UhdEx2rycetiLmf30LgCz5BCL9w8hfI8uVErCX595CK+UjbcbNioy1gYA5oO zz3VZrdg+wzg+Lh3RmMpa4eqnklBVgBCLc7fUd+jJQjaEDtGC47cWElTPw4IM8V9FQqd xehgOPiTZH1jPcLRilqf+7+elWc9+cVttvJU7QUi+A78S6uyS7aYZm0czdEUNCxQwwNr bEGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=uybE7F3i; 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 x9si428029oia.238.2020.02.25.19.26.41; Tue, 25 Feb 2020 19:26:54 -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; dkim=pass header.i=@joelfernandes.org header.s=google header.b=uybE7F3i; 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 S1729618AbgBZDZA (ORCPT + 99 others); Tue, 25 Feb 2020 22:25:00 -0500 Received: from mail-io1-f65.google.com ([209.85.166.65]:39191 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727880AbgBZDZA (ORCPT ); Tue, 25 Feb 2020 22:25:00 -0500 Received: by mail-io1-f65.google.com with SMTP id c16so1733619ioh.6 for ; Tue, 25 Feb 2020 19:25:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IOzAwCx4zkKExWVM/1JeparZOmVnpclobVkhjd9ROHU=; b=uybE7F3iZRKuDdGsl6AyNPinESePbWi00KedWrOiIi33XC+9m8T4hszY/5M8ZqDunR c9cmuFEToTMIUntwmJSVt7qJ7n6vT0NsDJbG4RGdP0gv6zADb9cZek3wTGJGGX4vG2h6 Ba12yAInTSh6EGdarC7pCOlFji5RczzdfgF7o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=IOzAwCx4zkKExWVM/1JeparZOmVnpclobVkhjd9ROHU=; b=M9ld1Dfty+W7gk0XlTD8mWlBhbZpWsBr8tW3UShWxwCQiOdCbbHT4yCfpW6/kfjMnV F7nEcQn6y1ca+zsF/elB47Ad+9B1X/je21qXEHSrZOqWZIcEQPvmVJL+kwtwUgLomWxb GR0c9fYmBzk97RAUoUN2v5diZ5Sc5DlNILgAsOVdQHWHbRwq4TwGIM7BERRvpmvPlJj1 hw8VvfjNkaiLIt/rd/TWThT7i59ivorCbEcoZOsO6xBzvmd4qGX65gCuVU7ESHi1h0Ra hs0x0JXw+cwEjpJqttLpq7fJmx1Fu5pK+fo0MZMpVl5zAZbBLBAXprhFNXBM+F7xrX6c JiiA== X-Gm-Message-State: APjAAAUUEh1yHYyJoEjEQvE1GUHlIrpDHswyWDodB4kIxRe0rTRaCICs mf5FyO50Q1LF8XSqOBTjI8B1h3QytsdqPVLylrEYgQ== X-Received: by 2002:a05:6638:6ba:: with SMTP id d26mr1761220jad.23.1582687499763; Tue, 25 Feb 2020 19:24:59 -0800 (PST) MIME-Version: 1.0 References: <1503467992.2999.1582234410317.JavaMail.zimbra@efficios.com> <20200221154923.GC194360@google.com> <1683022606.3452.1582301632640.JavaMail.zimbra@efficios.com> In-Reply-To: <1683022606.3452.1582301632640.JavaMail.zimbra@efficios.com> From: Joel Fernandes Date: Tue, 25 Feb 2020 22:24:48 -0500 Message-ID: Subject: Re: Rseq registration: Google tcmalloc vs glibc To: Mathieu Desnoyers Cc: Chris Kennelly , Paul Turner , Florian Weimer , "Carlos O'Donell" , libc-alpha , linux-kernel , Peter Zijlstra , paulmck , Boqun Feng , Brian Geffon Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 21, 2020 at 11:13 AM Mathieu Desnoyers wrote: > > ----- On Feb 21, 2020, at 10:49 AM, Joel Fernandes, Google joel@joelfernandes.org wrote: > > [...] > >> > >> 3) Use the __rseq_abi TLS cpu_id field to know whether Rseq has been > >> registered. > >> > >> - Current protocol in the most recent glibc integration patch set. > >> - Not supported yet by Linux kernel rseq selftests, > >> - Not supported yet by tcmalloc, > >> > >> Use the per-thread state to figure out whether each thread need to register > >> Rseq individually. > >> > >> Works for integration between a library which exists for the entire lifetime > >> of the executable (e.g. glibc) and other libraries. However, it does not > >> allow a set of libraries which are dlopen'd/dlclose'd to co-exist without > >> having a library like glibc handling the registration present. > > > > Mathieu, could you share more details about why during dlopen/close > > libraries we cannot use the same __rseq_abi TLS to detect that rseq was > > registered? > > Sure, > > A library which is only loaded and never closed during the execution of the > program can let the kernel implicitly unregister rseq at thread exit. For > the dlopen/dlclose use-case, we need to be able to explicitly unregister > each thread's __rseq_abi which sit in a library which is going to be > dlclose'd. Mathieu, Thanks a lot for the explanation, it makes complete sense. It sounds from Chris's reply that tcmalloc already checks __rseq_abi.cpu_id and is not dlopened/closed. Considering these, it seems to already handle things properly - CMIIW. Chris, Brian, is there any other concern to upgrading of tcmalloc version in ChromeOS? I believe there was some concern about detection of rseq kernel support. A quick look at tcmalloc shows it does not do such detection, but I can stand corrected. One more thing, currently tcmalloc does not use rseq on ARM. If I recall, ARM does have rseq support as well. So we ought to enable it for that arch as well if possible. Why not enable it on all arches and then dynamically detect at runtime if needed support is available? Thanks, Joel