Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1311346

Re: [PATCH v2] zsmalloc: fix migrate_zspage-zs_free race condition

From Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2] zsmalloc: fix migrate_zspage-zs_free race condition
Date 2016-01-18 08:10 +0100
Message-ID <qSc6R-5GF-5@gated-at.bofh.it> (permalink)
References (3 earlier) <qRqvf-7Hg-3@gated-at.bofh.it> <qRtMu-1ox-1@gated-at.bofh.it> <qRu5Q-1Kr-9@gated-at.bofh.it> <qRufw-1NG-9@gated-at.bofh.it> <qSbDP-5ho-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hello,

oh, you replied in this thread.

On (01/18/16 15:32), Minchan Kim wrote:
> >                 free_obj = obj_malloc(d_page, class, handle);
> >                 zs_object_copy(free_obj, used_obj, class);
> >                 index++;
> > +               /* This also effectively unpins the handle */
> >                 record_obj(handle, free_obj);
> > -               unpin_tag(handle);
> >                 obj_free(pool, class, used_obj);
> >         }
> > 
> > But I'd still recommend WRITE_ONCE in record_obj(). And I'm not even sure it's
> 
> Thanks for the reivew. Yeah, we need WRITE_ONCE in record_obj but
> your version will not work. IMHO, WRITE_ONCE can prevent store-tearing
> but it couldn't prevent reordering. IOW, we need some barrier as unlock
> and clear_bit_unlock includes it.
> So, we shouldn't omit unpin_tag there.

but there is only one store operation after this patch.

static void record_obj(unsigned long handle, unsigned long obj)
{
	*(unsigned long *)handle = obj;
}

does the re-ordering problem exist? zs_free() will see the
old pinned handle and spin, until record_obj() from migrate.

	-ss

> > safe on all architectures to do a simple overwrite of a word against somebody
> > else trying to lock a bit there?
> 
> Hmm, I think it shouldn't be a problem. It's word-alinged, word-sized
> store so it should be atomic.
> 
> As other example, we have been used lock_page for a bit of page->flags
> and used other bits in there with __set_bit(ie, __SetPageXXX).
> I guess it's same situation with us just except we are spinning there.
> But it is worth to dobule check so need to help lock guys.

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: [PATCH v2] zsmalloc: fix migrate_zspage-zs_free race condition Minchan Kim <minchan@kernel.org> - 2016-01-15 15:40 +0100
  Re: [PATCH v2] zsmalloc: fix migrate_zspage-zs_free race condition Vlastimil Babka <vbabka@suse.cz> - 2016-01-15 16:50 +0100
    Re: [PATCH v2] zsmalloc: fix migrate_zspage-zs_free race condition Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-01-16 05:20 +0100
      Re: [PATCH v2] zsmalloc: fix migrate_zspage-zs_free race condition Vlastimil Babka <vbabka@suse.cz> - 2016-01-16 08:50 +0100
        Re: [PATCH v2] zsmalloc: fix migrate_zspage-zs_free race condition Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-01-16 09:10 +0100
          Re: [PATCH v2] zsmalloc: fix migrate_zspage-zs_free race condition Vlastimil Babka <vbabka@suse.cz> - 2016-01-16 09:20 +0100
            Re: [PATCH v2] zsmalloc: fix migrate_zspage-zs_free race condition Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-01-16 11:10 +0100
              Re: [PATCH v2] zsmalloc: fix migrate_zspage-zs_free race condition Junil Lee <junil0814.lee@lge.com> - 2016-01-18 02:10 +0100
            Re: [PATCH v2] zsmalloc: fix migrate_zspage-zs_free race condition Minchan Kim <minchan@kernel.org> - 2016-01-18 07:40 +0100
              Re: [PATCH v2] zsmalloc: fix migrate_zspage-zs_free race condition Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-01-18 08:10 +0100

csiph-web