From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7976 invoked by alias); 6 Oct 2016 21:35:56 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 7960 invoked by uid 89); 6 Oct 2016 21:35:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy=rise, locks, Hx-languages-length:1679 X-HELO: mail-qk0-f172.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=35hlM88Wh767asS8YHq7Y7PutYduiiYzf3TzTTkGsxM=; b=hM+vRYO6CRzkqWjQAXujO3PWFuR7PKY4w9CdrSGuF6QX1b/dw641ES2xtJJ5UY2Uyq qDuH82QkXBMTHNKMrRtLYpaWjYF1a/0oTyHKXuy72pdEwExh9psXgXTpPax5grpTGjov 6/7UqrVrEQKzBvrnTle2XDien/GJXchjy5VJqlqz5Ytw2z24IXCP0LR7TWUDwpHFevvv w/OLeeXjSdcVeag0TsIeWFBit3JBCyubMlReDvFKgm+iG94uD2Wcna/x2jTQFHNSeHbz 51SWC1OIrnspViwwGkld3y3r+29wmsRBu7aYBDm1gNqjBnpwsMnCXu+bVngZ71jlOw98 nksw== X-Gm-Message-State: AA6/9RkNWlB5OPebm6IyhwF0U6sAfIyUVavNSt+djIpDOpc9bbN76wRRJFWI6RZroyUPLdV2pn/nnRUAIbs5lQ== X-Received: by 10.233.223.132 with SMTP id t126mr17621890qkf.107.1475789744256; Thu, 06 Oct 2016 14:35:44 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <20161006172631.GO19318@brightrain.aerifal.cx> <20161006180514.GP19318@brightrain.aerifal.cx> From: =?UTF-8?B?Um9iZXJ0IMWad2nEmWNraQ==?= Date: Thu, 06 Oct 2016 21:35:00 -0000 Message-ID: Subject: Re: Caching of PID/TID after fork To: Adhemerval Zanella Cc: GLIBC Devel Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SW-Source: 2016-10/txt/msg00154.txt.bz2 > Also, providing a glibc own symbol to update the tid/pid is messy: > it would be an internal implementation detail which in theory > application should not have access to, it might add some > synchronization issues (what happens if you try to force update > after a mutex operation with default wrong value?), and it also > might be tricky to add a compatibility symbol in case of change > how tid/pid internally works. Thanks, this is good analysis. > Another possibility is to use another thread unique identifier > as the owner instead of tid (maybe a hash of pthread_t > to fit on a int). By removing this requirement I think it is > feasible to get rid of caching. Another dev told me that chromium developers implemented ForkWithFlags - https://codereview.chromium.org/800183004/ - to deal exactly with the problem is caching PID/TID. They used the setjmp/longjmp approach suggested by Rich. My point is that a lot of projects which use the clone syscall will be hit by this problem, and getting to (or finding in glibc mail archives) the working solution might take a lot of time. It's because of the rise of namespaces, more and more projects will be using the syscall for various forms of containerization. Maybe providing something like fork_with_flags(int flags) would work here? Seems that most (all?) the projects that I've seen, which use clone() directly and had problems with caching of TID/PID, basically need fork with some flags (mainly of the CLONE_NEW* type). Such function would deal with tid/gid/locks/pthread_atfork as fork does, but would also OR the provided flags with the canonical ones? --=20 Robert =C5=9Awi=C4=99cki