Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp736624imb; Fri, 1 Mar 2019 12:35:44 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia7M/O6oeXizpEQJG9qx/bSVlmMkwA1l1xqUdpF43iVSLjvwYhAR+jc4zRBzpCuvzCj+EsN X-Received: by 2002:a62:1e82:: with SMTP id e124mr7513015pfe.258.1551472544407; Fri, 01 Mar 2019 12:35:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551472544; cv=none; d=google.com; s=arc-20160816; b=tU+Yf/vw0Jzg8ICjUwV73NLVwPJVs0OJ/F/VLtEGWEw7ZqGSJBOB/i88UhHCrvwjuD DiMyAkvEpGPfA2v0q0TyTCfRLaFh2uyCHbEOLiinix06NqOUbZhcd8BJWQZl+ZKwGi0o yRpmsa5sJjY2ws1cBfx0r0ZKyvKqNHbHAI6Q7WwM2Tz2NOoArLQm0+9ZJO8WdTHcCeoy AGXe646mlrc2XK0KBcWDZL7+va3gze+vJQxvTfW/sxdAQyNCm8SKIiwkwYt8pEktY4Tl tXjX0PiaoyKzEdRpl3zY/nZXniNcTH6zHIdRCgddWk2VZ1kz3HkQnt/JXVUBZChf3458 butw== 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; bh=g+Xalb+8bLs1bnYHMDuUYeNKMDZy9pBh98B7bBcq63s=; b=JYMhhqrvFhbul+cQNRKFErdg8X1vf48l0SAYafx2GVZIevaFG4cyFrF0dxT0gewLrK 7FQ3/kz51K6A36YW0JY3pgVufb1zvQA02wn/YuwbAzIpv1K56JqAooskn1sAiTVMTEPX bPL+xDiyqQNSzUL7z/ZbkIVEbYL4Mh+C/9ijh1gA6vYWgTXThWmvI8NAVs4FdqkH7iY6 M3NRxb1tJFFoJIaeMlXD8Ftnt74haRU6LU24FOhhqmJMvNHOOVLtwATxYjlDHhB7YJYS 8hnhiEbS2jhKRxxH/AOIn8B9kzTYn4eWGIvw3pQ+1VeR8KU10LO/DoHtS/YLKOOy18bK XNKA== 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c11si21030351pfn.233.2019.03.01.12.35.25; Fri, 01 Mar 2019 12:35:44 -0800 (PST) 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726001AbfCAUfA (ORCPT + 99 others); Fri, 1 Mar 2019 15:35:00 -0500 Received: from mail-yw1-f68.google.com ([209.85.161.68]:34798 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725862AbfCAUe7 (ORCPT ); Fri, 1 Mar 2019 15:34:59 -0500 Received: by mail-yw1-f68.google.com with SMTP id u205so15130667ywe.1 for ; Fri, 01 Mar 2019 12:34:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=g+Xalb+8bLs1bnYHMDuUYeNKMDZy9pBh98B7bBcq63s=; b=JCRj+uKEWI4QN8VV0Nai8ttuP54jaYMUG+TUc3BEagWNZn7LNWRvuDXhuIfAQ5+QQk VmZfkW7o+bAYi8A+QUi1tdyXnlduU48VIVAWepjZJ6vMT/gKJQiKzDMqDg5U2eenQXTU AuH2o4Asj8TGiqn3EyWo/ne19p0uxWjeTXwAPMcYWq+WKGoCm6JWaMkYpj7SSJtDhdqd KxdR2tbw7/zmiN1BAJ1ohM2E3g3cTL67iSwGVluusOc9x5wyhEvoQsxwfsJJJqjA9q8w ETJji0P2JNofeHkcY6sGngExtv2oT+z77nFGF3YcMTOpIeU7urkCkMTlWdzH4Vk/Ch3S bDSQ== X-Gm-Message-State: APjAAAW844kdCgr//qcgiUPZ6VmcmFJn7sn/QPcxHcuA+yB83bEtxkt6 dEuOBTUDcgpBkNeDeQP0oBY= X-Received: by 2002:a25:2e50:: with SMTP id b16mr6022764ybn.177.1551472498636; Fri, 01 Mar 2019 12:34:58 -0800 (PST) Received: from dennisz-mbp.dhcp.thefacebook.com ([2620:10d:c091:200::2:23c7]) by smtp.gmail.com with ESMTPSA id 130sm7759416ywp.54.2019.03.01.12.34.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Mar 2019 12:34:57 -0800 (PST) Date: Fri, 1 Mar 2019 15:34:55 -0500 From: Dennis Zhou To: Barret Rhoden Cc: Eial Czerwacki , dennis@kernel.org, tj@kernel.org, cl@linux.com, linux-kernel@vger.kernel.org, Shai Fultheim , Oren Twaig , "Paul E. McKenney" Subject: Re: [PATCH] percpu/module resevation: change resevation size iff X86_VSMP is set Message-ID: <20190301203455.GA97188@dennisz-mbp.dhcp.thefacebook.com> References: <1548071251-1849-1-git-send-email-eial@scalemp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Barret, On Fri, Mar 01, 2019 at 01:30:15PM -0500, Barret Rhoden wrote: > Hi - > > On 01/21/2019 06:47 AM, Eial Czerwacki wrote: > > > > Your main issue was that you only sent this patch to LKML, but not the > maintainers of the file. If you don't, your patch might get lost. To get > the appropriate people and lists, run: > > scripts/get_maintainer.pl YOUR_PATCH.patch. > > For this patch, you'll get this: > > Dennis Zhou (maintainer:PER-CPU MEMORY ALLOCATOR) > Tejun Heo (maintainer:PER-CPU MEMORY ALLOCATOR) > Christoph Lameter (maintainer:PER-CPU MEMORY ALLOCATOR) > linux-kernel@vger.kernel.org (open list) > > I added the three maintainers to this email. > > I have a few minor comments below. > > > [PATCH] percpu/module resevation: change resevation size iff X86_VSMP is > set > > You misspelled 'reservation'. Also, I'd just say: "percpu: increase module > reservation size if X86_VSMP is set". ('change' -> 'increase'), only says > 'reservation' once.) > > > as reported in bug #201339 (https://bugzilla.kernel.org/show_bug.cgi?id=201339) > > I think you can add a tag for this right above your Signed-off-by tags. > e.g.: > > Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=201339 > > > by enabling X86_VSMP, INTERNODE_CACHE_BYTES's definition differs from the default one > > causing the struct size to exceed the size ok 8KB. > ^of > > Which struct are you talking about? I have one in mind, but others might > not know from reading the commit message. > > I ran into this on https://bugzilla.kernel.org/show_bug.cgi?id=202511. In > that case, it was because modules (drm and amdkfd) were using DEFINE_SRCU, > which does a DEFINE_PER_CPU on struct srcu_data, and that used > ____cacheline_internodealigned_in_smp. > > > > > in order to avoid such issue, increse PERCPU_MODULE_RESERVE to 64KB if CONFIG_X86_VSMP is set. > ^increase > > > > > the value was caculated on linux 4.20.3, make allmodconfig all and the following oneliner: > ^calculated > > > for f in `find -name *.ko`; do echo $f; readelf -S $f |grep perc; done |grep data..percpu -B 1 |grep ko |while read r; do echo -n "$r: "; objdump --syms --section=.data..percpu $r|grep data |sort -n |awk '{c++; d=strtonum("0x" $1) + strtonum("0x" $5); if (m < d) m = d;} END {printf("%d vars-> last addr 0x%x ( %d )\n", c, m, m)}' ; done |column -t |sort -k 8 -n | awk '{print $8}'| paste -sd+ | bc > > Not sure how useful the one-liner is, versus a description of what you're > doing. i.e. "the size of all module percpu data sections, or something." > > Also, how close was that calculated value to 64K? If more modules start > using DEFINE_SRCU, each of which uses 8K, then that 64K might run out. > > Thanks, > Barret > > > Signed-off-by: Eial Czerwacki > > Signed-off-by: Shai Fultheim > > Signed-off-by: Oren Twaig > > --- > > include/linux/percpu.h | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/include/linux/percpu.h b/include/linux/percpu.h > > index 70b7123..6b79693 100644 > > --- a/include/linux/percpu.h > > +++ b/include/linux/percpu.h > > @@ -14,7 +14,11 @@ > > /* enough to cover all DEFINE_PER_CPUs in modules */ > > #ifdef CONFIG_MODULES > > +#ifdef X86_VSMP > > +#define PERCPU_MODULE_RESERVE (1 << 16) > > +#else > > #define PERCPU_MODULE_RESERVE (8 << 10) > > +#endif > > #else > > #define PERCPU_MODULE_RESERVE 0 > > #endif > > > Thanks for sending this to me. I must say, I really do not want to expand the reserved region. In most cases, it can easily end up unused and thus wasted memory as it is hard allocated on boot. This is done because code gen assumes static variables are close to the program counter. This would not be true with dynamic allocations which being at the end of the vmalloc area (Summarized from Tejun's account in [1]). Another note on the reserved region. It starts at the end of the static region which means it generally isn't page aligned. So while an 8kb allocation would fit, a 4kb alignment more than likely would fail. Something as large as 8kb should probably be dynamically allocated as well. I read through the bugzilla report and it seems that the culprits are: drivers/gpu/drm/amd/amdkfd/kfd_process.c:DEFINE_SRCU(kfd_processes_srcu); drivers/gpu/drm/drm_drv.c:DEFINE_STATIC_SRCU(drm_unplug_srcu); Is there a reason we cannot dynamically initialize these structs? I've cced Paul McKenney because we saw an issue with ipmi in December [1]. [1] https://lore.kernel.org/linux-mm/CAJM9R-JWO1P_qJzw2JboMH2dgPX7K1tF49nO5ojvf=iwGddXRQ@mail.gmail.com/ Thanks, Dennis