Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1311334
| Path | csiph.com!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | Minchan Kim <minchan@kernel.org> |
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v2] zsmalloc: fix migrate_zspage-zs_free race condition |
| Date | Mon, 18 Jan 2016 07:40:01 +0100 |
| Message-ID | <qSbDP-5ho-1@gated-at.bofh.it> (permalink) |
| References | <qR79g-2OU-23@gated-at.bofh.it> <qRdHI-7q5-17@gated-at.bofh.it> <qReNs-89q-9@gated-at.bofh.it> <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> |
| X-Original-Senderip | 156.147.1.127 |
| X-Original-Mailfrom | minchan@kernel.org |
| X-Original-Senderip | 165.244.98.150 |
| X-Original-Mailfrom | minchan@kernel.org |
| X-Original-Senderip | 10.177.223.161 |
| X-Original-Mailfrom | minchan@kernel.org |
| MIME-Version | 1.0 |
| User-Agent | Mutt/1.5.21 (2010-09-15) |
| X-Mimetrack | Itemize by SMTP Server on LGEKRMHUB03/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2016/01/18 15:30:22, Serialize by Router on LGEKRMHUB03/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2016/01/18 15:30:23, Serialize complete at 2016/01/18 15:30:23 |
| Content-Type | text/plain; charset="us-ascii" |
| Content-Disposition | inline |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 60 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Sergey Senozhatsky <sergey.senozhatsky@gmail.com>, Junil Lee <junil0814.lee@lge.com>, ngupta@vflare.org, sergey.senozhatsky.work@gmail.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org |
| X-Original-Date | Mon, 18 Jan 2016 15:32:46 +0900 |
| X-Original-Message-ID | <20160118063246.GB7453@bbox> |
| X-Original-References | <1452843551-4464-1-git-send-email-junil0814.lee@lge.com> <20160115143434.GA25332@blaptop.local> <56991514.9000609@suse.cz> <20160116040913.GA566@swordfish> <5699F4C9.1070902@suse.cz> <20160116080650.GB566@swordfish> <5699FC69.4010000@suse.cz> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1311334 |
Show key headers only | View raw
Hello, Vlastimil On Sat, Jan 16, 2016 at 09:16:41AM +0100, Vlastimil Babka wrote: > On 16.1.2016 9:06, Sergey Senozhatsky wrote: > > On (01/16/16 08:44), Vlastimil Babka wrote: > >> On 16.1.2016 5:09, Sergey Senozhatsky wrote: > >>> On (01/15/16 16:49), Vlastimil Babka wrote: > >> > >> Hmm but that's an unpin, not a pin? A mistake or I'm missing something? > > > > I'm sure it's just a compose-in-mail-app typo. > > BTW, couldn't the correct fix also just look like this? > > diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c > index 9f15bdd9163c..43f743175ede 100644 > --- a/mm/zsmalloc.c > +++ b/mm/zsmalloc.c > @@ -1635,8 +1635,8 @@ static int migrate_zspage(struct zs_pool *pool, struct > size_class *class, > 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. > 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. > > > -ss > > > >> Anyway the compiler can do the same thing here without a WRITE_ONCE(). > > > > -- > > To unsubscribe, send a message with 'unsubscribe linux-mm' in > > the body to majordomo@kvack.org. For more info on Linux MM, > > see: http://www.linux-mm.org/ . > > Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a> > > >
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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