Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp768491imb; Fri, 1 Mar 2019 13:29:02 -0800 (PST) X-Google-Smtp-Source: AHgI3IYOnfRG5NGUfG/K0z1I1k9BML6L7UpPC0gdoMqpTxo4D98sL6Mkw2KUV10GkgR+VqFGkc8U X-Received: by 2002:a62:e413:: with SMTP id r19mr7683926pfh.236.1551475742667; Fri, 01 Mar 2019 13:29:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551475742; cv=none; d=google.com; s=arc-20160816; b=GPwqKTG6KNSmtNB39BzTuxxI9fRqEmibPI55Zy8ETCHzrIBv3tbNmUsxNG2PsV4Uo6 hUnhD6hLA9ZSeTk7H++8mnPJpLcYUTIhoZDapgLvFhHKRnAFPw5sNLX98yWk9cmo0UUo k9kRxKH9gRwGXZyt+Q/zII81GO7NjHhoPEghj0AhUxBDATV1k3GaCHGWKkFZjVnqJEmA SSWNkekCkwhXrvAcmkZFMU9xuH+kQD+bhh94KWQNzrdjt/naDXa+hTI/AITP84fst2Vp v2XzRE+oJXgnOZZjDRa7thwW74Q6fHs7PaAWbCqY42zNjonxgSERTQumossf7BsXEfxo E1ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=enNvwB0scpSS/1buCvD824SgQhmWeVv3YrCaXdZ6YVw=; b=GCiVte/t/jgV/qNsRjfJqNVORR1j3RTJESlfWw5dVLfShDIUMnsV8oCd7mOeuEcsST zZXNjNMzarjKBos9aw2VNLXgqm7xUnpupMT51Z99rWx77Q3htKdo2Lseox0FptovP7fX QPJJcAWRCdBLpT5vGuaI5WYSJ2aculBSdhS9fM9PSFz7bISHVT0KU+/HT3WFiWgisZFu PifxPNfYa4GydKXEWL2iTiVe0R9pR56lQCYbHv6/d4pg0Dl8MhFN0geu8JyXU8Qx7KOz jB/ZZYnREa0pz8U8Juz/k2WRi+O75edcu1EWwLqKxKuXVnmZr7BMCJycGj8futOXnSHY CN1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Q6Vkdnnx; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l29si21026864pgu.82.2019.03.01.13.28.45; Fri, 01 Mar 2019 13:29:02 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=Q6Vkdnnx; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726038AbfCAV17 (ORCPT + 99 others); Fri, 1 Mar 2019 16:27:59 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:32911 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725905AbfCAV17 (ORCPT ); Fri, 1 Mar 2019 16:27:59 -0500 Received: by mail-pg1-f195.google.com with SMTP id h11so12041765pgl.0 for ; Fri, 01 Mar 2019 13:27:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=enNvwB0scpSS/1buCvD824SgQhmWeVv3YrCaXdZ6YVw=; b=Q6Vkdnnx86eUXJrEJx1rydKAQ5FH051EmCl1IxQ+tQNZlQNqEGW4mnx67xL5ibrVO+ 3IpeFIzZPpKWXUcxtxIZIdlRpB2ims2L0vk3OSObc1gQfAKucPLAm6nZZzn/wGYWjPRd 9nEOJ9n3tTBcojAaL/ptKfeOpTd/WqOlJdLIkL74Ww+E/MXFpfNgywlM/SxYX6lYXToa f67Pz1EuHEvtPzTQEegZa1ZAXLjNEsz/+/9TE1aIYQmOF4PNCv8XwTsqNOx8ZZsACl2w qpesLXPn31Ce60woDs1KlkIuxriraeA8MGAl5o3VQAHQBdiKWgD2CThu1pvadSGL3wns dZ/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=enNvwB0scpSS/1buCvD824SgQhmWeVv3YrCaXdZ6YVw=; b=nNUirWXDpagkagSsXbzQEn9TZO/9f6Uqi8kSIXer0bob+x1welDinAECLQNjH87WGv fvXriz9+XHAxvWaAT1tqwsbeS/y3EaA69OE6KKjzVvjDgaY2MSq6rW+u5UVcR/stZjXu Jz10GC1u8WP9D1d1g2S6KZiyy3UlbO5yyHOoMggZPybSoHEToe7N908wv5LJ3Cblq32u V6f2JlObh3tIoWzh2GGCGu+vyxzFOHt84N5GmhGBQUI2hjiJ7dQtFnGZeOrvRqCY5Xpb LJ3/U077WNC27FZ6wZZDxem0lKfkhxvDMsQtJ1nrzKK6tyVfHKb9GQFefhbn4G7xIk87 17Kw== X-Gm-Message-State: APjAAAU11Ru1WO5VaF1HCVaN5Sodg+jvjm+kaMKTN1cn850EGLqGie1V wQx+urfTz2KCI4d52PoVd8UZbw== X-Received: by 2002:a65:6548:: with SMTP id a8mr6928475pgw.103.1551475677687; Fri, 01 Mar 2019 13:27:57 -0800 (PST) Received: from gnomeregan.cam.corp.google.com ([2620:15c:6:14:ad22:1cbb:d8fa:7d55]) by smtp.googlemail.com with ESMTPSA id k27sm21334752pgb.70.2019.03.01.13.27.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Mar 2019 13:27:56 -0800 (PST) Subject: Re: [PATCH] percpu/module resevation: change resevation size iff X86_VSMP is set To: Dennis Zhou Cc: Eial Czerwacki , tj@kernel.org, cl@linux.com, linux-kernel@vger.kernel.org, Shai Fultheim , Oren Twaig , "Paul E. McKenney" References: <1548071251-1849-1-git-send-email-eial@scalemp.com> <20190301203455.GA97188@dennisz-mbp.dhcp.thefacebook.com> From: Barret Rhoden Message-ID: Date: Fri, 1 Mar 2019 16:27:54 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190301203455.GA97188@dennisz-mbp.dhcp.thefacebook.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi - On 03/01/2019 03:34 PM, Dennis Zhou wrote: > 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]. I looked at the AMD driver, and it looks like they could dynamically initialize it. It would require a little extra plumbing. I imagine the DRM one is the same way. To catch this in the future, should we disallow DEFINE_SRCU in modules or something? Otherwise, this will pop up again the next time someone uses DEFINE_SRCU in a module and builds with CONFIG_X86_VSMP. That might be a little much, and it still won't be sufficient to catch all cases. This will also come up any time a module has a static per-cpu data structure that uses __cacheline_aligned_in_smp, so it's not limited to SRCU either. I'm not familiar with VSMP - how bad is it to use L1 cache alignment instead of 4K page alignment? Maybe some structures can use the smaller alignment? Or maybe have VSMP require SRCU-using modules to be built-in? Thanks, Barret