linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Artem Bityutskiy <dedekind1@gmail.com>
To: Richard Weinberger <richard@nod.at>
Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/4] UBI: Fastmap: Care about the protection queue
Date: Mon, 13 Oct 2014 18:23:23 +0300	[thread overview]
Message-ID: <1413213803.7906.45.camel@sauron.fi.intel.com> (raw)
In-Reply-To: <543BE21F.5020504@nod.at>

On Mon, 2014-10-13 at 16:30 +0200, Richard Weinberger wrote:
> Am 13.10.2014 um 15:17 schrieb Artem Bityutskiy:
> > On Fri, 2014-10-03 at 21:06 +0200, Richard Weinberger wrote:
> >> Fastmap needs basically access to all internal state of UBI, which
> >> lives mostly
> >> within wl.c
> > 
> > Sounds like a very strong assertion, smells a bit fishy, need the
> > details.
> 
> Fastmap need to know the exact state of each PEB.
> I.e. is it free, used, scheduled for erase, etc...
> 
> >> It needs to iterate over the used, free, erase, scrub RB-trees, the
> >> protection queue, etc. to
> >> collect the exact state of all PEBs.
> > 
> > When? In 'ubi_write_fastmap()' when forming the FM pool data structures?
> 
> Yes.
> 
> > I think you can just add a function like this to wl.c:
> > 
> > int ubi_wl_get_peb_info(int pnum, struct ubi_wl_peb_info *pebinfo)
> > 
> > Yoy will give it the PEB number you are interested in, it will return
> > you the information you need in 'pebinfo'. The information will contain
> > the EC, the state (used, free, etc).
> > 
> > If you need just the EC, then you do not even need the ubi_wl_peb_info
> > data structure.
> > 
> > Then you just iterate over all PEBs and fill the FM pool data
> > structures.
> > 
> > Would something like this work?
> 
> The interface would work but some work in wl.c is needed.
> For example if I want to find out in which state PEB 1 is wl.c would have to
> look int free free, used free, protection queue, etc.. to tell me the state. This is slow.

Well, used and free are RB-trees, looking them up is slow.

If what you need is to go through all used and free PEBs, then you can
introduce some kind of

struct ubi_wl_entry *ubi_wl_get_next_used(struct ubi_wl_entry *prev)

function, and similar functions for the free.

I would return you the next entry (or NULL would indicate the end), and
it would take the previous entry as the input, or NULL for the first
call.

We'd need to take the locks before calling this function. This is
cleaner than what we do now, right?

> But we could add the state information to struct ubi_wl_entry by adding a single integer attribute called "state" or "flags".

But there is a price - memory consumption. We do not want to pay it just
for making the inter-subsystems boundaries better, there ought to be a
better reason.

Say, for an (imaginary) 8GiB NAND chip with 128KiB PEB size this would
cost 256KiB of RAM.

Squeezing the state into the last 2 bits a memory reference would be
another possibility, BTW. Not elegant, though...

> Would this make you happy? :)

Not very, I'd save this for the last resort solution.


  reply	other threads:[~2014-10-13 15:24 UTC|newest]

Thread overview: 45+ 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
2014-10-03 12:52           ` Artem Bityutskiy
2014-10-02 13:05   ` Tanya Brokhman
2014-10-02 13:18     ` Richard Weinberger
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 [this message]
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=1413213803.7906.45.camel@sauron.fi.intel.com \
    --to=dedekind1@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    /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).