Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp166682ybj; Mon, 4 May 2020 18:26:59 -0700 (PDT) X-Google-Smtp-Source: APiQypJOteLDtcB9MfRtfms9NMQk+KLZGTH123FHdEe/M1LZ0pOyAeA23uCZvKg+FldB8uXMtd7v X-Received: by 2002:a17:906:85c2:: with SMTP id i2mr571535ejy.147.1588642019270; Mon, 04 May 2020 18:26:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588642019; cv=none; d=google.com; s=arc-20160816; b=M+lIygVXswRQCjXfXY2veo4B1swHIJSHaupsv/Qmi4TxdXZcHKSmSWggV+SzOFqipZ m+TOAjdqg0kxMYWpUhF2Cvpl/eKmadmJoLvandEi5TZEzFLrHU4aXub9qmrm62sXhEfj xzAVQQUdxDod5ojToY+jBqcukP7hQElFu08CKhA3xpbHa3y1lzpvq/iprMODdwwHEIlp a/ZEVV4V4lqJu3vAxNMV4suDZp9/a0OI8KsD+RHluY2ZgsY+serCuFPAcWk8vtU36+D3 D0/+uckB7PTLJ+vBoD+8RSzYd6vDKFopSUMqOgxpe5WjQPL6Oqlfr3PQiSwtDAOabfPi 8n+w== 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:dkim-signature; bh=4+6154vKJTABEfgUtxKwWoHbT6y+LuZVgaWdQCoeaJ0=; b=LabMTKL5QlORy0caMCOqLLNoY1maTi+3dYN4ycWA0hgKgVz0e9ZG+g9/EMr3R29nBk n7Jet2tREjJV35/3YNlWVjaDBgkVB4BeP91yKwqu0pWweqCxBOiBd6CbBBCa1dpddaWD +SxPH4RKr7UKPAlOZs31qFiXW4HuxbdeX/g3NHsxglUGs9Ux6LZfeuQ72BrZ/oBiVUcD fwx1CzcdgmgpPGdpXqguItcxM8rfLS9mPD3CQ3EAX8esaiA6WPL8dU05X6U1M5OMk04g k1D4VmPjCnkQ1Tqcs13I5vOSD+VXtqQtSSSoBMsMOpII1F40wrxvx3EXsWL99Ex0wpyE scTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=CMoXkt2f; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cq19si333636edb.333.2020.05.04.18.26.26; Mon, 04 May 2020 18:26:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=CMoXkt2f; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726551AbgEEB0T (ORCPT + 99 others); Mon, 4 May 2020 21:26:19 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:45406 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726449AbgEEB0T (ORCPT ); Mon, 4 May 2020 21:26:19 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0451N6ko079996; Tue, 5 May 2020 01:25:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2020-01-29; bh=4+6154vKJTABEfgUtxKwWoHbT6y+LuZVgaWdQCoeaJ0=; b=CMoXkt2fWDkIg5JZiKjYVOxo/ricHIVKH25HA0ij33TZMT+wY45jvCYQ1I0ncaq/h1NB qTGq4sVubLO8srgRcnGcuaxePZrsKCdi/YRLHoAogCQU9kqPMpJhSqAnGf2eYzr33VSZ EZL17sihTk9pDALvtp5ha5AuhPBJO4DDIZcSa+LIFGJzQV4FZsdYIT8M8Lbv2xrXjg25 1u/utotOj/a1j5IPSo5O9g2wgmHJgrrqWtoQoV3FvI17KAcAGtoPsN21YTr4/BUpuxsG HnwQGsW2kh+uKh1shg3txe0iI5CNb5AO2yfpfEzsIJ40bQLlfWNro/WjgAMU003Wphux Vg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 30s0tma20x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 05 May 2020 01:25:48 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0451Lidr101980; Tue, 5 May 2020 01:25:48 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 30t1r3revy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 05 May 2020 01:25:47 +0000 Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0451PdNR022088; Tue, 5 May 2020 01:25:39 GMT Received: from ca-dmjordan1.us.oracle.com (/10.211.9.48) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 04 May 2020 18:25:39 -0700 Date: Mon, 4 May 2020 21:26:01 -0400 From: Daniel Jordan To: Alexander Duyck Cc: Daniel Jordan , Andrew Morton , Herbert Xu , Steffen Klassert , Alex Williamson , Alexander Duyck , Dan Williams , Dave Hansen , David Hildenbrand , Jason Gunthorpe , Jonathan Corbet , Josh Triplett , Kirill Tkhai , Michal Hocko , Pavel Machek , Pavel Tatashin , Peter Zijlstra , Randy Dunlap , Shile Zhang , Tejun Heo , Zi Yan , linux-crypto@vger.kernel.org, linux-mm , LKML Subject: Re: [PATCH 6/7] mm: parallelize deferred_init_memmap() Message-ID: <20200505012601.b7pdwbcc2v6gkghf@ca-dmjordan1.us.oracle.com> References: <20200430201125.532129-1-daniel.m.jordan@oracle.com> <20200430201125.532129-7-daniel.m.jordan@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9611 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 suspectscore=2 spamscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005050006 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9611 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 spamscore=0 suspectscore=2 phishscore=0 clxscore=1015 bulkscore=0 mlxlogscore=999 adultscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005050006 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon, May 04, 2020 at 03:33:58PM -0700, Alexander Duyck wrote: > On Thu, Apr 30, 2020 at 1:12 PM Daniel Jordan > > @@ -1778,15 +1798,25 @@ static int __init deferred_init_memmap(void *data) > > goto zone_empty; > > > > /* > > - * Initialize and free pages in MAX_ORDER sized increments so > > - * that we can avoid introducing any issues with the buddy > > - * allocator. > > + * More CPUs always led to greater speedups on tested systems, up to > > + * all the nodes' CPUs. Use all since the system is otherwise idle now. > > */ > > I would be curious about your data. That isn't what I have seen in the > past. Typically only up to about 8 or 10 CPUs gives you any benefit, > beyond that I was usually cache/memory bandwidth bound. I was surprised too! For most of its development, this set had an interface to get the number of cores on the theory that this was about where the bandwidth got saturated, but the data showed otherwise. There were diminishing returns, but they were more apparent on Haswell than Skylake for instance. I'll post some more data later in the thread where you guys are talking about it. > > > + max_threads = max(cpumask_weight(cpumask), 1u); > > + > > We will need to gather data on if having a ton of threads works for > all architectures. Agreed. I'll rope in some of the arch lists in the next version and include the debugging knob to vary the thread count. > For x86 I think we are freeing back pages in > pageblock_order sized chunks so we only have to touch them once in > initialize and then free the two pageblock_order chunks into the buddy > allocator. > > > for_each_free_mem_pfn_range_in_zone_from(i, zone, &spfn, &epfn) { > > - while (spfn < epfn) { > > - nr_pages += deferred_init_maxorder(zone, &spfn, epfn); > > - cond_resched(); > > - } > > + struct def_init_args args = { zone, ATOMIC_LONG_INIT(0) }; > > + struct padata_mt_job job = { > > + .thread_fn = deferred_init_memmap_chunk, > > + .fn_arg = &args, > > + .start = spfn, > > + .size = epfn - spfn, > > + .align = MAX_ORDER_NR_PAGES, > > + .min_chunk = MAX_ORDER_NR_PAGES, > > + .max_threads = max_threads, > > + }; > > + > > + padata_do_multithreaded(&job); > > + nr_pages += atomic_long_read(&args.nr_pages); > > } > > zone_empty: > > /* Sanity check that the next zone really is unpopulated */ > > Okay so looking at this I can see why you wanted to structure the > other patch the way you did. However I am not sure that is the best > way to go about doing it. It might make more sense to go through and > accumulate sections. If you hit the end of a range and the start of > the next range is in another section, then you split it as a new job, > otherwise I would just accumulate it into the current job. You then > could section align the work and be more or less guaranteed that each > worker thread should be generating finished work products, and not > incomplete max order pages. This guarantee holds now with the max-order alignment passed to padata, so I don't see what more doing it on section boundaries buys us.