All of lore.kernel.org
 help / color / mirror / Atom feed
From: Namjae Jeon <linkinjeon@gmail.com>
To: Rabin Vincent <rabin@rab.in>
Cc: fengguang.wu@intel.com, axboe@kernel.dk,
	linux-kernel@vger.kernel.org, chanho0207@gmail.com
Subject: Re: [PATCHv2] backing-dev: fix wakeup timer races with bdi_unregister()
Date: Fri, 20 Jan 2012 20:18:31 +0900	[thread overview]
Message-ID: <CAKYAXd8UuC0pAX7G7aG2q_3U_bPG8Bs_GpjxbfiX=9=Q+RW1Rg@mail.gmail.com> (raw)
In-Reply-To: <20120120100309.GA20640@debian>

2012/1/20 Rabin Vincent <rabin@rab.in>:
> On Fri, Jan 20, 2012 at 03:15:32PM +0900, Namjae Jeon wrote:
>> 2012/1/20 Rabin Vincent <rabin@rab.in>:
>> > On Fri, Jan 20, 2012 at 05:16, Namjae Jeon <linkinjeon@gmail.com> wrote:
>> >>>                bdi_debug_unregister(bdi);
>> >>> -               device_unregister(bdi->dev);
>> >>> +
>> >>> +               spin_lock_bh(&bdi->wb_lock);
>> >>>                bdi->dev = NULL;
>> >>> +               spin_unlock_bh(&bdi->wb_lock);
>> >> Hi.
>> >> Would you explain me why you add spinlock in here ?
>> >
>> > wakeup_timer_fn() does the following, where the
>> > trace_writeback_wake_forker_thread() also accesses bdi->dev.
>> > It does this under the wb_lock:
>> >
>> >        } else if (bdi->dev) {
>> >                /*
>> >                 * When bdi tasks are inactive for long time, they are killed.
>> >                 * In this case we have to wake-up the forker thread which
>> >                 * should create and run the bdi thread.
>> >                 */
>> >                trace_writeback_wake_forker_thread(bdi);
>> >
>> > If we don't have the lock above, the bdi->dev could potentially be
>> > cleared after the check but before the tracepoint is hit, leading to a
>> > NULL pointer dereference.
>> Is there no possibility trace_writeback_wake_forker_thread is called
>> after spin_unlock of bdi->de= null ?
>
> wakeup_timer_fn() holds the wb_lock across the check for bdi->dev !=
> NULL and the call to trace_writeback_wake_forker_thread(), so no.

The following case is not possible with racing of __mark_inode_dirty  ?
--------------------------------------------------------------------------------------------------
spin_lock
bdi->dev = NULL;
spin_unlock
                              spin_lock
                               ......
                               ......
                               trace_writeback_wake_forker_thread(bdi);
                               spin_unlock
-----------------------------------------------------------------------------

  reply	other threads:[~2012-01-20 11:18 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-05  8:49 [PATCH] mm/backing-dev.c: fix crash when USB/SCSI device is detached Chanho Min
2012-01-15 10:28 ` Rabin Vincent
2012-01-15 12:58   ` Wu Fengguang
2012-01-15 15:41     ` Rabin Vincent
2012-01-16  2:53       ` Wu Fengguang
2012-01-16  5:28         ` Chanho Min
2012-01-16  5:50           ` Wu Fengguang
2012-01-16  5:53             ` Wu Fengguang
2012-01-16  6:34               ` Chanho Min
2012-01-18 19:43                 ` Rabin Vincent
2012-01-19 16:50         ` [PATCHv2] backing-dev: fix wakeup timer races with bdi_unregister() Rabin Vincent
2012-01-19 23:46           ` Namjae Jeon
2012-01-20  5:24             ` Rabin Vincent
2012-01-20  6:15               ` Namjae Jeon
2012-01-20 10:03                 ` Rabin Vincent
2012-01-20 11:18                   ` Namjae Jeon [this message]
2012-01-20 12:08                     ` Rabin Vincent
2012-01-20 15:04                       ` Namjae Jeon
2012-01-31 13:24           ` Wu Fengguang

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='CAKYAXd8UuC0pAX7G7aG2q_3U_bPG8Bs_GpjxbfiX=9=Q+RW1Rg@mail.gmail.com' \
    --to=linkinjeon@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=chanho0207@gmail.com \
    --cc=fengguang.wu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rabin@rab.in \
    /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.