linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Richard Weinberger <richard@nod.at>
To: "Bityutskiy, Artem" <artem.bityutskiy@intel.com>
Cc: "linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"dedekind1@gmail.com" <dedekind1@gmail.com>
Subject: Re: [PATCH 1/4] UBI: Ensure that all fastmap work is done upon WL shutdown
Date: Tue, 30 Sep 2014 10:07:23 +0200	[thread overview]
Message-ID: <542A64BB.7060904@nod.at> (raw)
In-Reply-To: <1412063620.2379.12.camel@sauron.fi.intel.com>

Am 30.09.2014 09:53, schrieb Bityutskiy, Artem:
> On Tue, 2014-09-30 at 08:58 +0200, Richard Weinberger wrote:
>> Am 30.09.2014 08:26, schrieb Artem Bityutskiy:
>>> On Tue, 2014-09-30 at 00:20 +0200, Richard Weinberger wrote:
>>>> ...otherwise the deferred work might run after datastructures
>>>> got freed and corrupt memory.
>>>
>>> How can this happend? The background thread is stopped by this time
>>> already, so what are the other possibilities? And why is this
>>> fastmap-only?
>>
>> This has nothing do to with the background thread.
>> Fastmap has a work queue. If one fastmap work has been
>> scheuled we have to wait for it.
> 
> I expected a bit more explanation. But OK, here is what I think.
> 
> UBI consists of subsystems. Subsystems try to be more or less
> independent, whenever possible. They expose interface functions for
> other subsystems. Of course the split is not ideal, but we do our best.
> 
> * wl.c does wear-levelling.
> * wl.c does not do fastmap.
> * fastmap.c does fastmap.
> * I am unhappy seeing yet another ifdef to wl.c

I can warp it.

> * I am unhappy seeing wl.c calling 'flush_work(&ubi->fm_work)', because
> fastmap.c should deal with 'fm_work'. Or said differently, wl.c is not a
> fastmap queue baby-sitter. fastmap.c is.

But wl.c has to trigger the deferred fastmap work as only wl.c detects when it is
needed. I you want I can implement a ubi_fastmap_shutdown() in fastmap.c which
calls flush_work().
But I did it in wl.c to have it balanced. wl.c triggers and stops the fastmap work.

> Most UB subsystems have the init and close function. May be adding one
> for fastmap would help? Then you could flush whatever from
> 'ubi_wl_close()' ?
> 
> Historically the work queue was implemented in wl.c because wl.c was the
> only user of it.

What work queue are you talking about?
The fastmap work queue was added by me and has nothing to do with the UBI background
worker thread.

> If this layout is not good enough, we should probably extend it, may be
> separate work queue management out of wl.c.

One thing I can think of is getting completely rid of the UBI background thread
and convert it to a work queue. But I'm not sure if this would make things easier
for fastmap.

> But populating wl.c with macros and little "take care of this fatmap
> bit" stuff is a not going to lead to better code structure.

s/fatmap/fastmap. A Freudian slip? ;)

I spent already a full week on refactoring that code. My goal was
making ubi_update_fastmap() callable from within the wear_leveling_worker() to get
rid of the fastmap work queue completely.
After one week the new code was more complicated and ugly than the current one. :-\

Some background info:
Fastmap needs to create a snapshot of the UBI state.
This is why you cannot call it within an UBI work. As UBI works can run in parallel.
The fastmap creation does many things which can sleep. Most stuff in the wear_leveling_worker()
happens in atmoic context.

Thanks,
//richard

  reply	other threads:[~2014-09-30  8:07 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-29 22:20 UBI: Fastmap fixes - round one Richard Weinberger
2014-09-29 22:20 ` [PATCH 1/4] UBI: Ensure that all fastmap work is done upon WL shutdown Richard Weinberger
2014-09-30  6:26   ` Artem Bityutskiy
2014-09-30  6:58     ` Richard Weinberger
2014-09-30  7:53       ` Bityutskiy, Artem
2014-09-30  8:07         ` Richard Weinberger [this message]
2014-10-03 12:52           ` Artem Bityutskiy
2014-10-02 13:05   ` Tanya Brokhman
2014-10-02 13:18     ` Richard Weinberger
2014-10-02 13:38       ` Tanya Brokhman
2014-09-29 22:20 ` [PATCH 2/4] UBI: Fastmap: Calc fastmap size correctly Richard Weinberger
2014-10-02 13:14   ` Tanya Brokhman
2014-10-02 13:18     ` Richard Weinberger
2014-10-02 14:04   ` Tanya Brokhman
2014-10-03 14:38   ` Artem Bityutskiy
2014-09-29 22:20 ` [PATCH 3/4] UBI: Fastmap: Care about the protection queue Richard Weinberger
2014-10-02 13:28   ` Tanya Brokhman
2014-10-02 13:32     ` Richard Weinberger
2014-10-02 14:14       ` Tanya Brokhman
2014-10-03 14:31   ` Artem Bityutskiy
2014-10-03 19:06     ` Richard Weinberger
2014-10-13 13:17       ` Artem Bityutskiy
2014-10-13 14:30         ` Richard Weinberger
2014-10-13 15:23           ` Artem Bityutskiy
2014-10-13 15:28             ` Bityutskiy, Artem
2014-10-13 21:04             ` Richard Weinberger
2014-10-14 10:23               ` Artem Bityutskiy
2014-10-14 12:21                 ` Tanya Brokhman
2014-10-14 13:02                   ` Artem Bityutskiy
2014-10-14 13:35                     ` Tanya Brokhman
2014-10-16 10:06                 ` Richard Weinberger
2014-10-16 10:15                   ` Artem Bityutskiy
2014-10-16 11:07                     ` Richard Weinberger
2014-10-20 14:46                   ` Artem Bityutskiy
2014-10-20 15:17                     ` Richard Weinberger
2014-10-20 15:40                       ` Artem Bityutskiy
2014-10-20 15:59                         ` Richard Weinberger
2014-10-20 16:09                           ` Artem Bityutskiy
2014-10-20 16:17                             ` Richard Weinberger
2014-10-20 20:46                         ` Richard Weinberger
2014-09-29 22:20 ` [PATCH 4/4] UBI: Fastmap: Ensure that only one fastmap work is scheduled Richard Weinberger
2014-09-30  6:45   ` Bityutskiy, Artem
2014-09-30  6:59     ` Richard Weinberger
2014-09-30  7:39       ` Bityutskiy, Artem
2014-09-30  7:44         ` Richard Weinberger
2014-10-02 14:22           ` Tanya Brokhman

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=542A64BB.7060904@nod.at \
    --to=richard@nod.at \
    --cc=artem.bityutskiy@intel.com \
    --cc=dedekind1@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.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 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).