All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve Dickson <SteveD@redhat.com>
To: "Kornievskaia, Olga" <Olga.Kornievskaia@netapp.com>
Cc: "linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH v3 1/3] gssd: use pthreads to handle upcalls
Date: Wed, 27 Apr 2016 11:23:35 -0400	[thread overview]
Message-ID: <5720D977.10008@RedHat.com> (raw)
In-Reply-To: <59AF3631-819C-42E5-AB0D-3483590E279D@netapp.com>



On 04/27/2016 11:16 AM, Kornievskaia, Olga wrote:
> 
>> On Apr 27, 2016, at 10:54 AM, Steve Dickson <SteveD@redhat.com> wrote:
>>
>>
>>
>> On 04/25/2016 12:58 PM, Olga Kornievskaia wrote:
>>> Currently, to persevere global data over multiple mounts,
>>> the root process does not fork when handling an upcall.
>>> Instead on not-forking create a pthread to handle the
>>> upcall since global data can be shared among threads.
>>>
>>> Signed-off-by: Steve Dickson <steved@redhat.com>
>>> Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
>>> ---
>>> aclocal/libpthread.m4  | 13 +++++++++++++
>>> configure.ac           |  3 +++
>>> utils/gssd/Makefile.am |  3 ++-
>>> utils/gssd/gssd.c      | 45 ++++++++++++++++++++++++++++++++++++++++-----
>>> utils/gssd/gssd.h      |  5 +++++
>>> utils/gssd/gssd_proc.c | 49 ++++++++++++++++++-------------------------------
>>> utils/gssd/krb5_util.c |  3 +++
>>> 7 files changed, 84 insertions(+), 37 deletions(-)
>>> create mode 100644 aclocal/libpthread.m4
>>>
>>> diff --git a/aclocal/libpthread.m4 b/aclocal/libpthread.m4
>>> new file mode 100644
>>> index 0000000..e87d2a0
>>> --- /dev/null
>>> +++ b/aclocal/libpthread.m4
>>> @@ -0,0 +1,13 @@
>>> +dnl Checks for pthreads library and headers
>>> +dnl
>>> +AC_DEFUN([AC_LIBPTHREAD], [
>>> +
>>> +    dnl Check for library, but do not add -lpthreads to LIBS
>>> +    AC_CHECK_LIB([pthread], [pthread_create], [LIBPTHREAD=-lpthread],
>>> +                 [AC_MSG_ERROR([libpthread not found.])])
>>> +  AC_SUBST(LIBPTHREAD)
>>> +
>>> +  AC_CHECK_HEADERS([pthread.h], ,
>>> +                   [AC_MSG_ERROR([libpthread headers not found.])])
>>> +
>>> +])dnl
>>> diff --git a/configure.ac b/configure.ac
>>> index 25d2ba4..e0ecd61 100644
>>> --- a/configure.ac
>>> +++ b/configure.ac
>>> @@ -385,6 +385,9 @@ if test "$enable_gss" = yes; then
>>>   dnl Invoked after AC_KERBEROS_V5; AC_LIBRPCSECGSS needs to have KRBLIBS set
>>>   AC_LIBRPCSECGSS
>>>
>>> +  dnl Check for pthreads
>>> +  AC_LIBPTHREAD
>>> +
>>>   dnl librpcsecgss already has a dependency on libgssapi,
>>>   dnl but we need to make sure we get the right version
>>>   if test "$enable_gss" = yes; then
>>> diff --git a/utils/gssd/Makefile.am b/utils/gssd/Makefile.am
>>> index cb040b3..3f5f59a 100644
>>> --- a/utils/gssd/Makefile.am
>>> +++ b/utils/gssd/Makefile.am
>>> @@ -49,7 +49,8 @@ gssd_LDADD = \
>>> 	$(RPCSECGSS_LIBS) \
>>> 	$(KRBLIBS) \
>>> 	$(GSSAPI_LIBS) \
>>> -	$(LIBTIRPC)
>>> +	$(LIBTIRPC) \
>>> +	$(LIBPTHREAD)
>>>
>>> gssd_LDFLAGS = \
>>> 	$(KRBLDFLAGS)
>>> diff --git a/utils/gssd/gssd.c b/utils/gssd/gssd.c
>>> index e7cb07f..0b7ffca 100644
>>> --- a/utils/gssd/gssd.c
>>> +++ b/utils/gssd/gssd.c
>>> @@ -87,7 +87,9 @@ unsigned int  rpc_timeout = 5;
>>> char *preferred_realm = NULL;
>>> /* Avoid DNS reverse lookups on server names */
>>> static bool avoid_dns = true;
>>> -
>>> +int thread_started = false;
>>> +pthread_mutex_t pmutex = PTHREAD_MUTEX_INITIALIZER;
>>> +pthread_cond_t pcond = PTHREAD_COND_INITIALIZER;
>>>
>>> TAILQ_HEAD(topdir_list_head, topdir) topdir_list;
>>>
>>> @@ -361,20 +363,53 @@ gssd_destroy_client(struct clnt_info *clp)
>>>
>>> static void gssd_scan(void);
>>>
>>> +static void wait_for_child_and_detach(pthread_t th)
>>> +{
>>> +	pthread_mutex_lock(&pmutex);
>>> +	while (!thread_started)
>>> +		pthread_cond_wait(&pcond, &pmutex);
>>> +	thread_started = false;
>>> +	pthread_mutex_unlock(&pmutex);
>>> +	pthread_detach(th);
>>> +}
>> I was just looking at this... does it make more sense to
>> make these types of routines inline instead of allocating
>> stack space on every call... 
>>
>> With rpc.gssd, when running, is now involved every mount
>> (even sec=sys ones) so I'm wondering if inlining 4 new 
>> routines would buy us anything... 
>>
>> One down fall with inline routines it makes more
>> difficult to debug from gdb breakpoint point of view.
> 
> This doesn’t look like a function that we really 
> need to step into, does it? I think inlining it would be ok.
No it does not... inlining it is... 
> 
> I think the biggest saving would be to take the next step 
> and do the pool of threads that are pre-created (and thus 
> not taking time to be allocated for each upcall). Then we 
> need a way to make sure we cleanup any threads that might 
> be hanging for whatever reason.
This will be an excellent next step! 

steved.

  reply	other threads:[~2016-04-27 15:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-25 16:58 [RFC PATCH v3 0/3] adding pthread support to gssd Olga Kornievskaia
2016-04-25 16:58 ` [PATCH v3 1/3] gssd: use pthreads to handle upcalls Olga Kornievskaia
2016-04-27 14:54   ` Steve Dickson
2016-04-27 15:16     ` Kornievskaia, Olga
2016-04-27 15:23       ` Steve Dickson [this message]
     [not found]         ` <57DB10EC-2538-4191-B5D7-03D53FD1F9C9@netapp.com>
     [not found]           ` <FDB72BF5-75F1-4A03-84B5-F4E1A06263C8@netapp.com>
2016-04-27 17:50             ` Steve Dickson
2016-04-25 16:58 ` [PATCH v3 2/3] gssd: using syscalls directly to change thread's identity Olga Kornievskaia
2016-04-25 20:23   ` Jeff Layton
2016-04-25 21:34     ` Kornievskaia, Olga
2016-04-25 16:58 ` [PATCH v3 3/3] gssd: always call gss_krb5_ccache_name Olga Kornievskaia

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5720D977.10008@RedHat.com \
    --to=steved@redhat.com \
    --cc=Olga.Kornievskaia@netapp.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.