Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759091Ab0DBDvn (ORCPT ); Thu, 1 Apr 2010 23:51:43 -0400 Received: from exprod5og113.obsmtp.com ([64.18.0.26]:33450 "EHLO exprod5og113.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752944Ab0DBDvf (ORCPT ); Thu, 1 Apr 2010 23:51:35 -0400 MIME-Version: 1.0 In-Reply-To: References: Date: Fri, 2 Apr 2010 11:51:33 +0800 Message-ID: Subject: Re: [Question] race condition in mm/page_alloc.c regarding page->lru? From: TAO HU To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, "Ye Yuan.Bo-A22116" , Chang Qing-A21550 , linux-arm-kernel@lists.infradead.org Content-Type: multipart/mixed; boundary=001636cd737f2f8f39048338e541 X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 11811 Lines: 246 --001636cd737f2f8f39048338e541 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 2 patches related to page_alloc.c were applied. Does anyone see a connection between the 2 patches and the panic? NOTE: the full patches are attached. diff --git a/mm/page_alloc.c b/mm/page_alloc.c index a596bfd..34a29e2 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2551,6 +2551,20 @@ static inline unsigned long wait_table_bits(unsigned long size) #define LONG_ALIGN(x) (((x)+(sizeof(long))-1)&~((sizeof(long))-1)) /* + * Check if a pageblock contains reserved pages + */ +static int pageblock_is_reserved(unsigned long start_pfn) +{ + unsigned long end_pfn =3D start_pfn + pageblock_nr_pages; + unsigned long pfn; + + for (pfn =3D start_pfn; pfn < end_pfn; pfn++) + if (PageReserved(pfn_to_page(pfn))) + return 1; + return 0; +} + +/* * Mark a number of pageblocks as MIGRATE_RESERVE. The number * of blocks reserved is based on zone->pages_min. The memory within the * reserve will tend to store contiguous free pages. Setting min_free_kbyt= es @@ -2579,7 +2593,7 @@ static void setup_zone_migrate_reserve(struct zone *z= one) continue; /* Blocks with reserved pages will never free, skip them. */ - if (PageReserved(page)) + if (pageblock_is_reserved(pfn)) continue; block_migratetype =3D get_pageblock_migratetype(page); --=20 1.5.4.3 diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 5c44ed4..a596bfd 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -119,6 +119,7 @@ static char * const zone_names[MAX_NR_ZONES] =3D { }; int min_free_kbytes =3D 1024; +int min_free_order_shift =3D 1; unsigned long __meminitdata nr_kernel_pages; unsigned long __meminitdata nr_all_pages; @@ -1256,7 +1257,7 @@ int zone_watermark_ok(struct zone *z, int order, unsigned long mark, free_pages -=3D z->free_area[o].nr_free << o; /* Require fewer higher order pages to be free */ - min >>=3D 1; + min >>=3D min_free_order_shift; if (free_pages <=3D min) return 0; --=20 On Thu, Apr 1, 2010 at 12:05 PM, TAO HU wrote: > Hi, all > > We got a panic on our ARM (OMAP) based HW. > Our code is based on 2.6.29 kernel (last commit for mm/page_alloc.c is > cc2559bccc72767cb446f79b071d96c30c26439b) > > It appears to crash while going through pcp->list in > buffered_rmqueue() of mm/page_alloc.c after checking vmlinux. > "00100100" implies LIST_POISON1 that suggests a race condition between > list_add() and list_del() in my personal view. > However we not yet figure out locking problem regarding page.lru. > > Any known issues about race condition in mm/page_alloc.c? > And other hints are highly appreciated. > > =A0/* Find a page of the appropriate migrate type */ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (cold) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ... ... > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} else { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0list_for_each_entry(page, = &pcp->list, lru) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (page_p= rivate(page) =3D=3D migratetype) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0break; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > > <1>[120898.805267] Unable to handle kernel paging request at virtual > address 00100100 > <1>[120898.805633] pgd =3D c1560000 > <1>[120898.805786] [00100100] *pgd=3D897b3031, *pte=3D00000000, *ppte=3D0= 0000000 > <4>[120898.806457] Internal error: Oops: 17 [#1] PREEMPT > ... ... > <4>[120898.807861] CPU: 0 =A0 =A0Not tainted =A0(2.6.29-omap1 #1) > <4>[120898.808044] PC is at get_page_from_freelist+0x1d0/0x4b0 > <4>[120898.808227] LR is at get_page_from_freelist+0xc8/0x4b0 > <4>[120898.808563] pc : [] =A0 =A0lr : [] =A0 =A0psr:= 800000d3 > <4>[120898.808563] sp : c49fbd18 =A0ip : 00000000 =A0fp : c49fbd74 > <4>[120898.809020] r10: 00000000 =A0r9 : 001000e8 =A0r8 : 00000002 > <4>[120898.809204] r7 : 001200d2 =A0r6 : 60000053 =A0r5 : c0507c4c =A0r4 = : c49fa000 > <4>[120898.809509] r3 : 001000e8 =A0r2 : 00100100 =A0r1 : c0507c6c =A0r0 = : 00000001 > <4>[120898.809844] Flags: Nzcv =A0IRQs off =A0FIQs off =A0Mode SVC_32 =A0= ISA > ARM =A0Segment kernel > <4>[120898.810028] Control: 10c5387d =A0Table: 82160019 =A0DAC: 00000017 > <4>[120898.948425] Backtrace: > <4>[120898.948760] [] (get_page_from_freelist+0x0/0x4b0) > from [] (__alloc_pages_internal+0xac/0x3e8) > <4>[120898.949554] [] (__alloc_pages_internal+0x0/0x3e8) > from [] (handle_mm_fault+0x16c/0xbac) > <4>[120898.950347] [] (handle_mm_fault+0x0/0xbac) from > [] (__get_user_pages+0x174/0x2b4) > <4>[120898.951019] [] (__get_user_pages+0x0/0x2b4) from > [] (get_user_pages+0x3c/0x44) > <4>[120898.951812] [] (get_user_pages+0x0/0x44) from > [] (get_arg_page+0x50/0xa4) > <4>[120898.952636] [] (get_arg_page+0x0/0xa4) from > [] (copy_strings+0x108/0x210) > <4>[120898.953430] =A0r7:beffffe4 r6:00000ffc r5:00000000 r4:00000018 > <4>[120898.954223] [] (copy_strings+0x0/0x210) from > [] (copy_strings_kernel+0x3c/0x74) > <4>[120898.955047] [] (copy_strings_kernel+0x0/0x74) from > [] (do_execve+0x18c/0x2b0) > <4>[120898.955841] =A0r5:0001e240 r4:0001e224 > <4>[120898.956329] [] (do_execve+0x0/0x2b0) from > [] (sys_execve+0x3c/0x5c) > <4>[120898.957153] [] (sys_execve+0x0/0x5c) from > [] (ret_fast_syscall+0x0/0x2c) > <4>[120898.957946] =A0r7:0000000b r6:0001e270 r5:00000000 r4:0001d580 > <4>[120898.958740] Code: e1530008 0a000006 e2429018 e1a03009 (e5b32018) > > > > -- > Best Regards > Hu Tao > --001636cd737f2f8f39048338e541 Content-Type: application/octet-stream; name="0001-mm-Add-min_free_order_shift-tunable.patch" Content-Disposition: attachment; filename="0001-mm-Add-min_free_order_shift-tunable.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_g7igdsiu0 RnJvbSBkNjIwZjY5NTI5MGU0ZmZiMTU4NjQyMGJhMWRiYmI1YjJjOGMwNzVkIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiA9P3V0Zi04P3E/QXJ2ZT0yMEhqPUMzPUI4bm5ldj1DMz1BNWc/ PSA8YXJ2ZUBhbmRyb2lkLmNvbT4KRGF0ZTogVHVlLCAxNyBGZWIgMjAwOSAxNDo1MTowMiAtMDgw MApTdWJqZWN0OiBbUEFUQ0hdIG1tOiBBZGQgbWluX2ZyZWVfb3JkZXJfc2hpZnQgdHVuYWJsZS4K TUlNRS1WZXJzaW9uOiAxLjAKQ29udGVudC1UeXBlOiB0ZXh0L3BsYWluOyBjaGFyc2V0PXV0Zi04 CkNvbnRlbnQtVHJhbnNmZXItRW5jb2Rpbmc6IDhiaXQKCkJ5IGRlZmF1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HotPmZyZWVfYXJlYVtvXS5ucl9m cmVlIDw8IG87CiAKIAkJLyogUmVxdWlyZSBmZXdlciBoaWdoZXIgb3JkZXIgcGFnZXMgdG8gYmUg ZnJlZSAqLwotCQltaW4gPj49IDE7CisJCW1pbiA+Pj0gbWluX2ZyZWVfb3JkZXJfc2hpZnQ7CiAK IAkJaWYgKGZyZWVfcGFnZXMgPD0gbWluKQogCQkJcmV0dXJuIDA7Ci0tIAoxLjUuNC4zCgo= --001636cd737f2f8f39048338e541 Content-Type: application/octet-stream; name="0002-mm-Check-if-any-page-in-a-pageblock-is-reserved-bef.patch" Content-Disposition: attachment; filename="0002-mm-Check-if-any-page-in-a-pageblock-is-reserved-bef.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_g7iged1u1 RnJvbSBhNGViMjA0YTgwMjkzMjBjMmRkNzQ4ZGFmNGY1MWZkNDhkMzM3YzNkIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiA9P3V0Zi04P3E/QXJ2ZT0yMEhqPUMzPUI4bm5ldj1DMz1BNWc/ PSA8YXJ2ZUBhbmRyb2lkLmNvbT4KRGF0ZTogV2VkLCAxOCBNYXIgMjAwOSAxNzoyNzozMSAtMDcw MApTdWJqZWN0OiBbUEFUQ0hdIG1tOiBDaGVjayBpZiBhbnkgcGFnZSBpbiBhIHBhZ2VibG9jayBp cyByZXNlcnZlZCBiZWZvcmUgbWFya2luZyBpdCBNSUdSQVRFX1JFU0VSVkUKClRoaXMgZml4ZXMg YSBwcm9ibGVtIHdoZXJlIHRoZSBmaXJzdCBwYWdlYmxvY2sgZ290IG1hcmtlZCBNSUdSQVRFX1JF U0VSVkUgZXZlbgp0aG91Z2ggaXQgb25seSBoYWQgYSBmZXcgZnJlZSBwYWdlcy4gVGhpcyBpbiB0 dXJuIGNhdXNlZCBubyBjb250aWd1b3VzIG1lbW9yeQp0byBiZSByZXNlcnZlZCBhbmQgZnJlcXVl bnQga3N3YXBkIHdha2V1cHMgd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GUgbnVtYmVyCiAgKiBvZiBibG9ja3MgcmVzZXJ2ZWQg aXMgYmFzZWQgb24gem9uZS0+cGFnZXNfbWluLiBUaGUgbWVtb3J5IHdpdGhpbiB0aGUKICAqIHJl c2VydmUgd2lsbCB0ZW5kIHRvIHN0b3JlIGNvbnRpZ3VvdXMgZnJlZSBwYWdlcy4gU2V0dGluZyBt aW5fZnJlZV9rYnl0ZXMKQEAgLTI1NzksNyArMjU5Myw3IEBAIHN0YXRpYyB2b2lkIHNldHVwX3pv bmVfbWlncmF0ZV9yZXNlcnZlKHN0cnVjdCB6b25lICp6b25lKQogCQkJY29udGludWU7CiAKIAkJ LyogQmxvY2tzIHdpdGggcmVzZXJ2ZWQgcGFnZXMgd2lsbCBuZXZlciBmcmVlLCBza2lwIHRoZW0u ICovCi0JCWlmIChQYWdlUmVzZXJ2ZWQocGFnZSkpCisJCWlmIChwYWdlYmxvY2tfaXNfcmVzZXJ2 ZWQocGZuKSkKIAkJCWNvbnRpbnVlOwogCiAJCWJsb2NrX21pZ3JhdGV0eXBlID0gZ2V0X3BhZ2Vi bG9ja19taWdyYXRldHlwZShwYWdlKTsKLS0gCjEuNS40LjMKCg== --001636cd737f2f8f39048338e541-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/