LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@linux-foundation.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Jaroslav Kysela <perex@suse.cz>,
	LKML <linux-kernel@vger.kernel.org>,
	Oleg Nesterov <oleg@tv-sign.ru>,
	netdev@vger.kernel.org
Subject: Re: [PATCH] bonding: replace system timer with work queue
Date: Thu, 01 Mar 2007 08:00:37 -0800	[thread overview]
Message-ID: <45E6F8A5.3010302@linux-foundation.org> (raw)
In-Reply-To: <20070228233512.d2d275a2.akpm@linux-foundation.org>

Andrew Morton wrote:
> On Wed, 28 Feb 2007 10:12:01 +0100 (CET) Jaroslav Kysela <perex@suse.cz> wrote:
>
>   
>> Hi,
>>
>> 	please, review and apply to mm tree for further testing. The patch 
>> is also available at 
>> ftp://ftp.alsa-project.org/pub/kernel-patches/bonding-workqueue.patch .
>>     
>
> Please cc netdev@vger.kernel.org on net-related patches, thanks.
>
>   
>> 					Thank you,
>> 						Jaroslav
>>
>> ==================
>> bonding: replace system timer with work queue
>>
>> This patch replaces system timer with work queue in monitor functions.
>> The reason for this change is that bonding handlers calls various
>> sleeping functions from the timer handler which is not allowed.
>>     
>
> Which sleeping functions?  I'd have expected the kernel to spew runtime
> warnings when this happens, but I don't recall any such reports.
>
>
>   
>> Because we cannot share the main workqueue threads (rtnl_lock is used
>> also in linkwatch_event) - new bond workqueue thread is created.
>>
>> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
>>
>> diff -rupN linux-2.6.20.orig/drivers/net/bonding/bond_3ad.c linux-2.6.20/drivers/net/bonding/bond_3ad.c
>> --- linux-2.6.20.orig/drivers/net/bonding/bond_3ad.c	2007-02-04 19:44:54.000000000 +0100
>> +++ linux-2.6.20/drivers/net/bonding/bond_3ad.c	2007-02-28 09:19:43.831369202 +0100
>> @@ -2097,8 +2097,10 @@ void bond_3ad_unbind_slave(struct slave 
>>   * times out, and it selects an aggregator for the ports that are yet not
>>   * related to any aggregator, and selects the active aggregator for a bond.
>>   */
>> -void bond_3ad_state_machine_handler(struct bonding *bond)
>> +void bond_3ad_state_machine_handler(struct work_struct *work)
>>  {
>> +	struct ad_bond_info *ad_info = container_of(work, struct ad_bond_info, ad_work.work);
>> +	struct bonding *bond = (struct bonding *)((char *)ad_info - offsetof(struct bonding, ad_info));
>>     
>
> We can use containers_of here too?
>
>   
>> -void bond_alb_monitor(struct bonding *bond)
>> +void bond_alb_monitor(struct work_struct *work)
>>  {
>> -	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
>> +	struct alb_bond_info *bond_info = container_of(work, struct alb_bond_info, alb_work.work);
>> +	struct bonding *bond = (struct bonding *)((char *)bond_info - offsetof(struct bonding, alb_info));
>>     
>
> And here.
>
>   
>> +		cancel_rearming_delayed_workqueue(bond_wq, &(BOND_AD_INFO(bond).ad_work));
>>     

As I mentioned earlier this call to cancel_rearming_delayed_workqueue 
can deadlock
with netlink_watch. This happens if:

dev_close
    rtnl_lock                     carrier lost on device
    bond_close                 netlink related workqueue event waiting 
for rtnl
       cancel_workqueue
          spinning waiting for workq to drain

The agreed upon semantics is to never do any operation that waits for workq
to drain with RTNL held.


  reply	other threads:[~2007-03-01 16:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-28  9:12 Jaroslav Kysela
2007-02-28 22:18 ` Stephen Hemminger
2007-03-01  7:35 ` Andrew Morton
2007-03-01 16:00   ` Stephen Hemminger [this message]
2007-03-01 17:00   ` Jay Vosburgh

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=45E6F8A5.3010302@linux-foundation.org \
    --to=shemminger@linux-foundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=oleg@tv-sign.ru \
    --cc=perex@suse.cz \
    --subject='Re: [PATCH] bonding: replace system timer with work queue' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).