[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2] tools/xenstore: try to get minimum thread stack size for watch thread



On 02/03/18 15:28, Wei Liu wrote:
> On Fri, Mar 02, 2018 at 01:45:14PM +0100, Juergen Gross wrote:
>> On 02/03/18 13:40, Wei Liu wrote:
>>> On Fri, Mar 02, 2018 at 12:29:31PM +0000, Wei Liu wrote:
>>>> On Mon, Feb 26, 2018 at 09:53:38AM -0700, Jim Fehlig wrote:
>>>>> On 02/26/2018 01:46 AM, Juergen Gross wrote:
>>>>>> When creating a pthread in xs_watch() try to get the minimal needed
>>>>>> size of the thread from glibc instead of using a constant. This avoids
>>>>>> problems when the library is used in programs with large per-thread
>>>>>> memory.
>>>>>>
>>>>>> Use dlsym() to get the pointer to __pthread_get_minstack() in order to
>>>>>> avoid linkage problems and fall back to the current constant size if
>>>>>> not found.
>>>>>>
>>>>>> Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
>>>>>> ---
>>>>>> V2:
>>>>>> - use _GNU_SOURCE (Wei Liu)
>>>>>> - call __pthread_get_minstack() with parameter
>>>>>> - add -ldl to correct make flags
>>>>>> - ensure to not using smaller stack size than today
>>>>>> ---
>>>>>>   tools/xenstore/Makefile |  4 ++++
>>>>>>   tools/xenstore/xs.c     | 21 ++++++++++++++++++++-
>>>>>>   2 files changed, 24 insertions(+), 1 deletion(-)
>>>>>>
>>>>>> diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile
>>>>>> index 2b99d2bc1b..0831be0b6f 100644
>>>>>> --- a/tools/xenstore/Makefile
>>>>>> +++ b/tools/xenstore/Makefile
>>>>>> @@ -100,6 +100,10 @@ libxenstore.so.$(MAJOR): 
>>>>>> libxenstore.so.$(MAJOR).$(MINOR)
>>>>>>          ln -sf $< $@
>>>>>>   xs.opic: CFLAGS += -DUSE_PTHREAD
>>>>>> +ifeq ($(CONFIG_Linux),y)
>>>>>> +xs.opic: CFLAGS += -DUSE_DLSYM
>>>>>> +libxenstore.so.$(MAJOR).$(MINOR): LDFLAGS += -ldl
>>>>>> +endif
>>>>>
>>>>> Dropping this patch in one of my automated builds caused a libxenstore 
>>>>> link failure
>>>>>
>>>>> [   99s] gcc    -lsystemd -ldl -pthread -Wl,-soname -Wl,libxenstore.so.3.0
>>>>> -shared -o libxenstore.so.3.0.3 xs.opic xs_lib.opic 
>>>>> /home/abuild/rpmbuild/BUILD/xen-4.10.0-testing/tools/xenstore/../../tools/libs/toolcore/libxentoolcore.so
>>>>>
>>>>> [   99s] 
>>>>> /home/abuild/rpmbuild/BUILD/xen-4.10.0-testing/tools/xenstore/../../tools/xenstore/libxenstore.so:
>>>>> undefined reference to `dlsym'
>>>>>
>>>>> I hacked around it by appending '-ldl' to the end of the subsequent
>>>>> libxenstore.so rule.
>>>>
>>>> Hmm... Maybe I'm a bit dense today. I know the position of -l matters
>>>> but I don't quite understand how placing -pthread before xs.opic works
>>>> but -ldl doesn't. xs.c uses both after all.
>>>
>>> I'm indeed very dense -- -pthread is a special option that sets the
>>> proper flags for linking pthread library for both the preprocessor and
>>> linker.
>>>
>>> But still, Juergen must have tested the change, so I wonder why it
>>> doesn't work in your setup. What is your build environment? Gcc version?
>>
>> And why is "-lsystemd" working correctly?
> 
> That's red-herring because libxenstore doesn't use systemd functions.
> The only place systemd is used is in xenstored_core.c -- calling
> sd_notify.

Nevertheless it is working:

# ldd /usr/lib64/libxenstore.so.3.0
        linux-vdso.so.1 (0x00007ffdfcbc6000)
        libsystemd.so.0 => /usr/lib64/libsystemd.so.0 (0x00007f1d054cb000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f1d052c7000)
        libxentoolcore.so.1 => /usr/lib64/libxentoolcore.so.1
(0x00007f1d050c5000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f1d04ea8000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f1d04b01000)
        liblzma.so.5 => /usr/lib64/liblzma.so.5 (0x00007f1d048db000)
        libgcrypt.so.20 => /usr/lib64/libgcrypt.so.20 (0x00007f1d045f5000)
        librt.so.1 => /lib64/librt.so.1 (0x00007f1d043ed000)
        libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f1d041d6000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f1d05900000)
        libgpg-error.so.0 => /usr/lib64/libgpg-error.so.0
(0x00007f1d03fd1000)

> But we still need to figure out why -ldl works in your setup but not
> Jim's.

I just rebuilt libxenstore.so and the xenstore clients. I've verified
all components are installed from the new build and working properly.

So obviously there are some differences in tooling.

What about using SHLIB_LDFLAGS instead of LDFLAGS?


Juergen

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.