All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sven Wegener <sven.wegener@stealer.net>
To: Christoph Hellwig <hch@infradead.org>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC] ipvs: Cleanup sync daemon code
Date: Sun, 10 Feb 2008 12:51:27 +0100 (CET)	[thread overview]
Message-ID: <Pine.LNX.4.64.0802101236530.15729@titan.stealer.net> (raw)
In-Reply-To: <20080210045952.GA8255@infradead.org>

On Sat, 9 Feb 2008, Christoph Hellwig wrote:

> On Sun, Feb 10, 2008 at 12:38:11AM +0100, Sven Wegener wrote:
>>  struct ip_vs_sync_thread_data {
>> -	struct completion *startup;
>> +	struct completion *startup; /* set to NULL once completed */
>
> This is not needed anmore.  kthread_run guarantees that the newly
> creates thread is run before returning to the caller.

The completion is currently used to return an error code for errors that 
happen during initialization in the threads (open socket, allocate 
memory). We could move the setup code out of the threads and have them 
only run an error-safe loop.

>> +/* wait queue for master sync daemon */
>> +static DECLARE_WAIT_QUEUE_HEAD(sync_master_wait);
>
> I don't think you need this one either.  You can use wake_up_process
> on the task_struct pointer instead.

Thanks, now using schedule_timeout with wake_up_process.

>>  	spin_lock(&ip_vs_sync_lock);
>>  	list_add_tail(&sb->list, &ip_vs_sync_queue);
>> +	if (++ip_vs_sync_count == 10)
>> +		wake_up_interruptible(&sync_master_wait);
>>  	spin_unlock(&ip_vs_sync_lock);
>>  }
>
>> -static int sync_thread(void *startup)
>> +static int sync_thread(void *data)
>
> Btw, it might make sense to remove sync_thread and just call the
> master and backup threads directly.

When the setup code has been moved out of the threads, the code gets much 
simpler.

>> +void __init ip_vs_sync_init(void)
>> +{
>> +	/* set up multicast address */
>> +	mcast_addr.sin_family = AF_INET;
>> +	mcast_addr.sin_port = htons(IP_VS_SYNC_PORT);
>> +	mcast_addr.sin_addr.s_addr = htonl(IP_VS_SYNC_GROUP);
>>  }
>
> Why can't this be initialized at compile time by:
>
> static struct sockaddr_in mcast_addr = {
> 	.sin_family		= AF_INET,
> 	.sin_port		= htons(IP_VS_SYNC_PORT),
> 	.sin_addr.s_addr	= htonl(IP_VS_SYNC_GROUP),
> }
>
> (the hton* might need __constant_hton* also I'm not sure without trying)

Thanks.

      reply	other threads:[~2008-02-10 11:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-09 23:38 [RFC] ipvs: Cleanup sync daemon code Sven Wegener
2008-02-10  1:27 ` Simon Horman
2008-02-10  4:59 ` Christoph Hellwig
2008-02-10 11:51   ` Sven Wegener [this message]

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=Pine.LNX.4.64.0802101236530.15729@titan.stealer.net \
    --to=sven.wegener@stealer.net \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@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.