RE: [openib-general] Re: [PATCH][26/26] IB: MAD cancel callbacks fromthread

From: Sean Hefty (sean.hefty_at_intel.com)
Date: 03/04/05

  • Next message: Pierre Ossman: "Re: intel 8x0 went silent in 2.6.11"
    To: "'Jeff Garzik'" <jgarzik@pobox.com>, "Roland Dreier" <roland@topspin.com>
    Date:	Thu, 3 Mar 2005 16:34:43 -0800
    
    

    >Roland Dreier wrote:
    >> +void cancel_sends(void *data)
    >> +{
    >> + struct ib_mad_agent_private *mad_agent_priv;
    >> + struct ib_mad_send_wr_private *mad_send_wr;
    >> + struct ib_mad_send_wc mad_send_wc;
    >> + unsigned long flags;
    >> +
    >> + mad_agent_priv = (struct ib_mad_agent_private *)data;
    >
    >don't add casts to a void pointer, that's silly.

    This is my bad.

    >> + mad_send_wc.status = IB_WC_WR_FLUSH_ERR;
    >> + mad_send_wc.vendor_err = 0;
    >> +
    >> + spin_lock_irqsave(&mad_agent_priv->lock, flags);
    >> + while (!list_empty(&mad_agent_priv->canceled_list)) {
    >> + mad_send_wr = list_entry(mad_agent_priv->canceled_list.next,
    >> + struct ib_mad_send_wr_private,
    >> + agent_list);
    >> +
    >> + list_del(&mad_send_wr->agent_list);
    >> + spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
    >> +
    >> + mad_send_wc.wr_id = mad_send_wr->wr_id;
    >> + mad_agent_priv->agent.send_handler(&mad_agent_priv->agent,
    >> + &mad_send_wc);
    >> +
    >> + kfree(mad_send_wr);
    >> + if (atomic_dec_and_test(&mad_agent_priv->refcount))
    >> + wake_up(&mad_agent_priv->wait);
    >> + spin_lock_irqsave(&mad_agent_priv->lock, flags);
    >> + }
    >> + spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
    >
    >dumb question... why is the lock dropped? is it just for the
    >send_handler(), or also for wr_id assigned, kfree, and wake_up() ?

    The lock is dropped to avoid calling the user back with it held. The if
    statement / wake_up call near the bottom of the loop can be replaced with a
    simple atomic_dec. The test should always fail. The lock is to protect
    access to the canceled_list.

    (Sorry about the mailer...)

    - Sean

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/


  • Next message: Pierre Ossman: "Re: intel 8x0 went silent in 2.6.11"

    Relevant Pages

    • [PATCH] NULL pointer deref in tcp_do_twkill_work()
      ... Shouldn't the loop always restart from the beginning instead of using the ... The alternative is to not drop the lock, but I'm guessing we need to do ... Proposed patch is attached. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [patch] Real-Time Preemption, -RT-2.6.12-rc1-V0.7.41-07
      ... With kjournald spinning on a bit lock until it finishes it's ... Although it only deadlocks on your system if it was a real-time task, ... highest priority task on the system, ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [RFC][PATCH] O(1) Entitlement Based Scheduler
      ... >> of a single CPU's capacity that the task may use. ... The task is removed from the runqueue and a timer is scheduled to put it ... > A holds lock that can not be unlocked, ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • [PATCH] Missing BKL in sys_chroot() for 2.6
      ... (PLEASE cc me on replies as I'm not subscribed). ... void set_fs_root(struct fs_struct *fs, struct vfsmount *mnt, ... * Requires the big lock held. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: kswapd in tight loop 2.6.9-rc3-bk-recent
      ... > appear to touch vmscan or mm/ in general). ... I also wonder if it'll lock up if just the first zone has ->all_unreclaimable. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)