Received: by 10.192.165.148 with SMTP id m20csp3250439imm; Mon, 23 Apr 2018 03:22:36 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/6f7qwzjWTMONTLBmZaa3Ehprhk9tPeEqUGC5pIQ+Dk/b7VB+al+2RmAOR9xdv+UUak7r6 X-Received: by 10.99.8.135 with SMTP id 129mr11004548pgi.17.1524478956593; Mon, 23 Apr 2018 03:22:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524478956; cv=none; d=google.com; s=arc-20160816; b=KlJg1NJxsgBflrrtfuTgx9lLQPeFnlsk+zSh8xQuHDNgk6LM7upoiDFtz9hNX+BnB1 PUFmEDuTvDa9swZVj6Ic2ZNZ0WqlyJj8ouEFpuag+nH0T4PaVaoJQrxs7HvpGUMSngeG nPsnXwQoAEVK3IvWMfCuZxJKPLCAaoneYQcqslAoZOrlpFIuOVcIr6/hrnsb2im36K83 IU2SfBX9/STR4WPpP59OS9qzch3zs/EIQM9AIYTBLoQYPFsqPA9KgCiq801ppiyqyDPO l0CzB5zTtkWN1kS4rwj+NSwcu06JXsv9Jk1wjy6kO8oCQOVrrnoGAq8nGqERw5ClOMH5 9xkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:date:message-id:in-reply-to :references:from:subject:cc:to:arc-authentication-results; bh=xCV5YNE015F5/u6ZmvFrjaKmhQYLkft9VeV7rZrKzrs=; b=kdZ0+Jm66eHsWQtSD4UsF1n9tZdmzUNfr79O+mrsuvcmkiowxmvKCswuwopJ0II3qL OjD5IR72znqWhzmZwUwvCwBg+IZomvN4EfMzt9jHchwFQJ4Af9aKeehMJIkpZMkTeolq STfca5aya31fFsZHrYG/GltOQpVp0z49fXygV9dQWXDzBk32jgk3oyfYQRAqPVl0sDox 6l2TnElSrvEm1mP4Yz8TrCzr/JQlbv3UZOcQqicHE8+wGMOqX7boN/3tJ0ICTPlen/Ts fp95Owr9EW9ZGTqizqq58cMYwWJv0JzYPze+VzoO1oG9GiFWT89EiXHGBlYJmH6DjtnS AZSA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j84si6610471pfk.203.2018.04.23.03.22.22; Mon, 23 Apr 2018 03:22:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754614AbeDWKVM (ORCPT + 99 others); Mon, 23 Apr 2018 06:21:12 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:19974 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753109AbeDWKVL (ORCPT ); Mon, 23 Apr 2018 06:21:11 -0400 Received: from fsav404.sakura.ne.jp (fsav404.sakura.ne.jp [133.242.250.103]) by www262.sakura.ne.jp (8.14.5/8.14.5) with ESMTP id w3NAL9H3050347; Mon, 23 Apr 2018 19:21:09 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav404.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav404.sakura.ne.jp); Mon, 23 Apr 2018 19:21:09 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav404.sakura.ne.jp) Received: from AQUA (softbank126099184120.bbtec.net [126.99.184.120]) (authenticated bits=0) by www262.sakura.ne.jp (8.14.5/8.14.5) with ESMTP id w3NAL9oA050344; Mon, 23 Apr 2018 19:21:09 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) To: gregkh@linuxfoundation.org, ben@decadent.org.uk Cc: linux-kernel@vger.kernel.org, tytso@mit.edu, stable@vger.kernel.org, jannh@google.com, stable@kernel.org, carnil@debian.org Subject: Re: [PATCH 4.9 75/95] random: set up the NUMA crng instances after the CRNG is fully initialized From: Tetsuo Handa References: <20180422135210.432103639@linuxfoundation.org> <20180422135213.491879480@linuxfoundation.org> <49fa7d5f484a06f02946afec0688c33849e018de.camel@decadent.org.uk> <20180423071520.GC28186@kroah.com> In-Reply-To: <20180423071520.GC28186@kroah.com> Message-Id: <201804231921.DGB18791.QOVFLFMJFtSOHO@I-love.SAKURA.ne.jp> X-Mailer: Winbiff [Version 2.51 PL2] X-Accept-Language: ja,en,zh Date: Mon, 23 Apr 2018 19:21:10 +0900 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Greg Kroah-Hartman wrote: > > I think this can be fixed by backporting commit 4a072c71f49b > > "random: silence compiler warnings and fix race" but I'm not sure > > whether that depends on other changes. > > According to Tetsuo Handa, it's also causing problems in mainline :( > > Ted, any thoughts as to what to do here? (Resending because Webmail post was rejected by both stable ML and linux-kernel ML.) Subject: random: GFP_KERNEL|__GFP_NOFAIL allocation from IRQ context Hello. Commit 8ef35c866f8862df ("random: set up the NUMA crng instances after the CRNG is fully initialized") is causing sleep inside atomic warning due to GFP_KERNEL|__GFP_NOFAIL allocation from IRQ context. Though it unlikely sleeps because there will be enough free memory at boot up... Please don't backport that patch now. [ 9.712722] BUG: sleeping function called from invalid context at mm/slab.h:421 [ 9.715231] in_atomic(): 1, irqs_disabled(): 0, pid: 0, name: swapper/2 [ 9.717396] INFO: lockdep is turned off. [ 9.718717] CPU: 2 PID: 0 Comm: swapper/2 Not tainted 4.17.0-rc1+ #480 [ 9.720857] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 05/19/2017 [ 9.724328] Call Trace: [ 9.725176] [ 9.725880] dump_stack+0xb1/0xfc [ 9.727003] ___might_sleep+0x23e/0x270 [ 9.728285] __might_sleep+0x45/0x80 [ 9.729479] __kmalloc+0x284/0x3e0 [ 9.730642] ? crng_reseed+0x122/0x320 [ 9.731876] crng_reseed+0x122/0x320 [ 9.733078] credit_entropy_bits+0x2f6/0x370 [ 9.734503] ? add_timer_randomness+0xb8/0xd0 [ 9.735880] add_timer_randomness+0xb8/0xd0 [ 9.737201] add_disk_randomness+0x32/0x170 [ 9.738666] scsi_end_request+0x182/0x210 [ 9.740004] scsi_io_completion+0x2cd/0x620 [ 9.741448] scsi_finish_command+0xf3/0x170 [ 9.742844] scsi_softirq_done+0x12b/0x170 [ 9.744209] blk_done_softirq+0xb2/0xd0 [ 9.745501] __do_softirq+0xcf/0x49b [ 9.746726] irq_exit+0xbc/0xd0 [ 9.747785] smp_call_function_single_interrupt+0x17a/0x270 [ 9.749603] call_function_single_interrupt+0xf/0x20 [ 9.751240] [ 9.751970] RIP: 0010:native_safe_halt+0x6/0x10 [ 9.753467] RSP: 0018:ffff88011963fe78 EFLAGS: 00000286 ORIG_RAX: ffffffffffffff04 [ 9.755922] RAX: ffff880119626380 RBX: ffff880119626380 RCX: 0000000000000000 [ 9.758362] RDX: ffff880119626380 RSI: 0000000000000001 RDI: ffff880119626380 [ 9.760743] RBP: ffff88011963fe78 R08: 0000000000000000 R09: 0000000000000000 [ 9.763068] R10: 0000000000000001 R11: ffff88011a4a3693 R12: 0000000000000002 [ 9.765382] R13: 0000000000000000 R14: 0000000000000000 R15: ffff880119626380 [ 9.767709] ? trace_hardirqs_on+0xd/0x10 [ 9.769044] default_idle+0x2c/0x1a0 [ 9.770333] arch_cpu_idle+0x10/0x20 [ 9.771526] default_idle_call+0x1e/0x40 [ 9.772833] do_idle+0x196/0x2a0 [ 9.773923] ? complete+0x48/0x50 [ 9.775068] cpu_startup_entry+0x5f/0x62 [ 9.776392] start_secondary+0x1a3/0x1f0 [ 9.777697] secondary_startup_64+0xa5/0xb0 [ 9.779101] random: crng init done # ./scripts/faddr2line vmlinux crng_reseed+0x122/0x320 crng_reseed+0x122/0x320: kmalloc_array at include/linux/slab.h:631 626 { 627 if (size != 0 && n > SIZE_MAX / size) 628 return NULL; 629 if (__builtin_constant_p(n) && __builtin_constant_p(size)) 630 return kmalloc(n * size, flags); 631 return __kmalloc(n * size, flags); 632 } 633 634 /** 635 * kcalloc - allocate memory for an array. The memory is set to zero. 636 * @n: number of elements. (inlined by) kcalloc at include/linux/slab.h:642 637 * @size: element size. 638 * @flags: the type of memory to allocate (see kmalloc). 639 */ 640 static inline void *kcalloc(size_t n, size_t size, gfp_t flags) 641 { 642 return kmalloc_array(n, size, flags | __GFP_ZERO); 643 } 644 645 /* 646 * kmalloc_track_caller is a special version of kmalloc that records the 647 * calling function of the routine calling it for slab leak tracking instead (inlined by) numa_crng_init at drivers/char/random.c:798 793 { 794 int i; 795 struct crng_state *crng; 796 struct crng_state **pool; 797 798 pool = kcalloc(nr_node_ids, sizeof(*pool), GFP_KERNEL|__GFP_NOFAIL); 799 for_each_online_node(i) { 800 crng = kmalloc_node(sizeof(struct crng_state), 801 GFP_KERNEL | __GFP_NOFAIL, i); 802 spin_lock_init(&crng->lock); 803 crng_initialize(crng); (inlined by) crng_reseed at drivers/char/random.c:923 918 memzero_explicit(&buf, sizeof(buf)); 919 crng->init_time = jiffies; 920 spin_unlock_irqrestore(&crng->lock, flags); 921 if (crng == &primary_crng && crng_init < 2) { 922 invalidate_batched_entropy(); 923 numa_crng_init(); 924 crng_init = 2; 925 process_random_ready_list(); 926 wake_up_interruptible(&crng_init_wait); 927 pr_notice("random: crng init done\n"); 928 }