Received: by 10.223.164.221 with SMTP id h29csp999680wrb; Wed, 1 Nov 2017 08:49:45 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TliRN2dFPYUNLnFOi++NeW7lrs6ReGuerI7t+2levakh//Vcf/LCMyF7buWiaByYZZXSPr X-Received: by 10.99.97.132 with SMTP id v126mr310634pgb.179.1509551385605; Wed, 01 Nov 2017 08:49:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509551385; cv=none; d=google.com; s=arc-20160816; b=wfr+4XW0tv5oRb169v5Dqd012xjAqFckdBkjU+dQUOQm3aM5MfPalmzdhzpPp1ANMX 38mi7sxYdC9HIwosIdEeEElKqsgUkCGKOdtSS6iw2OFlIgQZtm4tzQrhKnLgqkl+vXKc 0X6+abaAy85iftFAnD0b/L2GZ2Vjcgz6rYR+RYSM/Dz1ZC3FCnx/Q3PmGnBrDug3UYyJ EChI+CdaKrxF08jPRpW95b7r1gQIQkygc1Uli/RMV+dGdiVi+fbBx8cfJYjI9ilQVeXB C0dzYOp6BsUe3BsIBYB2JZgFBRAiOVLTRaJLsPV0TweX2Be42c4I212hHimZv6/Mgh9J zwDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dmarc-filter:arc-authentication-results; bh=lRFeynQThfOdNvdhuo1JhqPqg+NLGOUytaROVUiiKrc=; b=xv+6B6pHolrmrUBjeGlC5S0NC0UD2AMCevMKn19+nLb702/U1zbzVeUkWKlmVMYyvU yUOfVxc6ivkmst/96/VmyP7RUDFvhSPNh04RTu6t7SFPKz+ZiHf82QyvCqAHhCdDQyWu FUmNrrmAPKvhOOiXCszQ2mr+nAXjrMSZRzTfZofYvjIOw8SGxMs+tYqJCBewIOh3mghm QXxZyMBnC3qdkZZ8PqjAhJ9VBWNww2hado3RgJ+3xmsXl1yvM/90rDb22imxZ5qOol1j B9ydL6c0Fp9sIt0wy4odkJekW++bNvnWk1vhxXZ9yMw8yrzMSf5SVYX7i91RIVL1ZQg/ GjNQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r26si1508412pfd.2.2017.11.01.08.49.31; Wed, 01 Nov 2017 08:49:45 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754560AbdKAPst (ORCPT + 99 others); Wed, 1 Nov 2017 11:48:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56620 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751347AbdKAPsr (ORCPT ); Wed, 1 Nov 2017 11:48:47 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9FD8E25C26; Wed, 1 Nov 2017 15:48:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9FD8E25C26 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=msnitzer@redhat.com Received: from localhost (unknown [10.18.25.149]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2F7EB60618; Wed, 1 Nov 2017 15:48:45 +0000 (UTC) Date: Wed, 1 Nov 2017 11:48:44 -0400 From: Mike Snitzer To: Mikulas Patocka Cc: Zdenek Kabelac , "Alasdair G. Kergon" , dm-devel@redhat.com, "Paul E. McKenney" , linux-kernel@vger.kernel.org Subject: SRCU's apparent use of NR_CPUS? [was: re: dm: allocate struct mapped_device with kvzalloc] Message-ID: <20171101154844.GA25792@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 01 Nov 2017 15:48:47 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [cc'ing Paul, and LKML, to get his/others' take on SRCU cpu scaling] On Tue, Oct 31 2017 at 7:33pm -0400, Mikulas Patocka wrote: > The structure srcu_struct can be very big, its size is proportional to the > value CONFIG_NR_CPUS. The Fedora kernel has CONFIG_NR_CPUS 8192, the field > io_barrier in the struct mapped_device has 84kB in the debugging kernel > and 50kB in the non-debugging kernel. The large size may result in failure > of the function kzalloc_node. > > In order to avoid the allocation failure, we use the function > kvzalloc_node, this function falls back to vmalloc if a large contiguous > chunk of memory is not available. This patch also moves the field > io_barrier to the last position of struct mapped_device - the reason is > that on many processor architectures, short memory offsets result in > smaller code than long memory offsets - on x86-64 it reduces code size by > 320 bytes. > > Note to stable kernel maintainers - the kernels 4.11 and older don't have > the function kvzalloc_node, you can use the function vzalloc_node instead. > > Signed-off-by: Mikulas Patocka > Cc: stable@vger.kernel.org This looks reasonable as a near-term workaround.. BUT: Paul has there been any discussion about how to make SRCU support dynamically scaling up to NR_CPUS maximum as 'nr_cpus' changes (rather than accounting for worst case of NR_CPUS up-front)? (But I had a quick look at scrutree.h and I'm not seeing explicit use of NR_CPUS, so it is likely occuring via implicit percpu through some member of 'struct srcu_struct', e.g. 'sda'?) Thanks, Mike > > --- > drivers/md/dm-core.h | 3 ++- > drivers/md/dm.c | 6 +++--- > 2 files changed, 5 insertions(+), 4 deletions(-) > > Index: linux-2.6/drivers/md/dm-core.h > =================================================================== > --- linux-2.6.orig/drivers/md/dm-core.h > +++ linux-2.6/drivers/md/dm-core.h > @@ -29,7 +29,6 @@ struct dm_kobject_holder { > * DM targets must _not_ deference a mapped_device to directly access its members! > */ > struct mapped_device { > - struct srcu_struct io_barrier; > struct mutex suspend_lock; > > /* > @@ -127,6 +126,8 @@ struct mapped_device { > struct blk_mq_tag_set *tag_set; > bool use_blk_mq:1; > bool init_tio_pdu:1; > + > + struct srcu_struct io_barrier; > }; > > void dm_init_md_queue(struct mapped_device *md); > Index: linux-2.6/drivers/md/dm.c > =================================================================== > --- linux-2.6.orig/drivers/md/dm.c > +++ linux-2.6/drivers/md/dm.c > @@ -1695,7 +1695,7 @@ static struct mapped_device *alloc_dev(i > struct mapped_device *md; > void *old_md; > > - md = kzalloc_node(sizeof(*md), GFP_KERNEL, numa_node_id); > + md = kvzalloc_node(sizeof(*md), GFP_KERNEL, numa_node_id); > if (!md) { > DMWARN("unable to allocate device, out of memory."); > return NULL; > @@ -1795,7 +1795,7 @@ bad_io_barrier: > bad_minor: > module_put(THIS_MODULE); > bad_module_get: > - kfree(md); > + kvfree(md); > return NULL; > } > > @@ -1814,7 +1814,7 @@ static void free_dev(struct mapped_devic > free_minor(minor); > > module_put(THIS_MODULE); > - kfree(md); > + kvfree(md); > } > > static void __bind_mempools(struct mapped_device *md, struct dm_table *t) From 1583309917271022872@xxx Mon Nov 06 09:53:23 +0000 2017 X-GM-THRID: 1583309674418084489 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread