summaryrefslogtreecommitdiff
path: root/open_issues/glibc/t/tls-threadvar.mdwn
blob: 5f1345c6f170d5364649c356b7193c1346d50046 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
[[!meta copyright="Copyright © 2011, 2012, 2013 Free Software Foundation,
Inc."]]

[[!meta license="""[[!toggle id="license" text="GFDL 1.2+"]][[!toggleable
id="license" text="Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU Free Documentation License, Version 1.2 or
any later version published by the Free Software Foundation; with no Invariant
Sections, no Front-Cover Texts, and no Back-Cover Texts.  A copy of the license
is included in the section entitled [[GNU Free Documentation
License|/fdl]]."]]"""]]

[[!tag open_issue_glibc open_issue_libpthread]]

This basically means to get rid of `sysdeps/mach/hurd/bits/libc-tsd.h` (and
thus the `_HURD_THREADVAR_*`/`_hurd_threadvar_location` interface), and
directly use `__thread` instead.

[[!toc]]


# IRC, freenode, #hurd, 2011-10-23

    <tschwinge> youpi: If we want to replace threadvars with TLS, there is one
      problem: the threadvars interface is publically exported:
      /usr/include/hurd/threadvar.h.
    <tschwinge> youpi: But I am somewhat inclined to say that the only user of
      this is libthreads/libpthread.  Do you think differently?
    <youpi> tschwinge: that's very probable
    <youpi> so I think we can just drop it
    <youpi> (people should use TLS anyway)

[[libpthread_set_stack_size]].

After this has been done, probably the whole `__libc_tsd_*` stuff can be
dropped altogether, and `__thread` directly be used in glibc.


# IRC, freenode, #hurd, 2012-08-07

    <tschwinge> r5219: Update libpthread patch to replace threadvar with tls
      for pthread_self
    <tschwinge> r5224: revert r5219 too, it's not ready either
    <youpi> as the changelog says, the __thread revertal is because it posed
      problems
    <youpi> and I just didn't have any time to check them while the freeze was
      so close
    <tschwinge> OK.  What kind of problems?  Should it be reverted upstream,
      too?
    <youpi> I don't remember exactly
    <youpi> it should just be fixed
    <youpi> we can revert it upstream, but it'd be good that we manage to
      progress, at some point...
    <tschwinge> Of course -- however as long as we don't know what kind of
      problem, it is a bit difficult.  ;-)
    <youpi> since I didn't left a note, it was most probably a mere glibc run,
      or boot with the patched libpthread
    <youpi> *testsuite run
    <tschwinge> OK.
    <tschwinge> The libpthread testsuite doesn't show any issues with that
      patch applied, though.  But I didn'T test anything else.
    <tschwinge> youpi: Also, you have probably seen my glibc __thread errno
      email -- rmcgrath wanted to find some time this week to comment/help, and
      I take it you don't have any immediate comments to that issue?
    <youpi> I saw the mails, but didn't investigate at all

[[!message-id "878vdyqht3.fsf@kepler.schwinge.homeip.net"]].


# `getcontext`/`setcontext`

Needed for [[gccgo]].

Instead of adding support for `getcontext`/`setcontext` within the Hurd
threadvar context, which might become a bit ugly, the idea is to get rid of
Hurd threadvars and replace them with TLS (as we want to, anyway).


## IRC, freenode, #hurd, 2012-04-19

    <gnu_srs> How much work/knowledge is needed to implement
      getcontext/setcontext?
    <gnu_srs> Any already implemented alternatives available?
    <youpi> x86 registers knowledge, as well as unix signal masks
    <youpi> there's the linux implementation that can be taken as an
      exxample, but the signal part has to be rewritten
    <gnu_srs> Well, it's a pity they are not implemented. That's the
      remaining hurdle to get gccgo working :-( 
    <youpi> uh :/
    <gnu_srs> Everything builds, but the testsuite fails due to these
      missing functions.
    <gnu_srs> Regarding getcontext/setcontext they seem to be written
      in assembly for linux but the code is not very long. 
    <gnu_srs> How much effort would it be to write something similar
      for Hurd? Anybody fluent in asm?
    <gnu_srs> And registers and signals.
    <tschwinge> gnu_srs: Signals is the key thing -- everything else we
      can probably just copy.  I have never/not yet looked at it,
      though.
    <gnu_srs> For kfreebsd it is written in C: kern_context.c, 3/4 in
      one file: getcontext, setcontext,  swapcontext, not makecontext.
    <gnu_srs> Dunno how much assembly calls used though.
    <gnu_srs> Hi, any preferences about implementing get/setcontext in
      C or Asm?
    <tschwinge> gnu_srs: I think these will have to be implemented in
      assembly.  Based on the Linux x86 variants.


### IRC, freenode, #hurd, 2012-04-20

    <tschwinge> youpi: Your understanding of that is better than mine
      -- the *context stuff can't be very useful at the moment, because
      when the user changes uc_stack.ss_sp (which the glibc tests are
      doing), we're losing access to the _hurd_threadvars.  Correct?
    <tschwinge> At least the getcontext test works, the other get a
      SIGILL.
    <tschwinge> others
    <tschwinge> _hurd_threadvars issue is just guessing.
    <youpi> tschwinge: yes, threadvars are on the stack
    <youpi> threadvars is not much code, it should just work, but care
      has to be taken on the libpthread/libthread side, which does some
      initialization
    <tschwinge> OK, that at least matches my understanding.