Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp593209imm; Thu, 26 Jul 2018 08:42:14 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeNZ3ceGRsQaE3vNv1NkIoHxXHdipRxJ7++9Q90fNJ8YDc0mWyGFVI4ZbQwrZKH7l/XRN5R X-Received: by 2002:a63:220d:: with SMTP id i13-v6mr2502944pgi.212.1532619734227; Thu, 26 Jul 2018 08:42:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532619734; cv=none; d=google.com; s=arc-20160816; b=Db4VGjoJUUCWs2YGKrQZ+DtfHwddcZoiOj25CSjErSQ8TdvwlMqYsvOYC9Fk3VFStO oZhi+1oPKP1/VPxa209at7+KZ1C2msSVCpNBfQc/HJk4ZsrB+1VIoYXrp0z41/O+R+Wy 7tT+f/qk+naQaOnuFxGJWWMR7RN0HStOI63YnfTaBQZfVi63WAySth5NapncrsG8SAwK ls3x7d6TiW7gi+uIqwNsrj2r2m6IF8sfl09yjC7Gqo4cUdrbV/Bvmg+fgUBSWPIDPHrm uyKiEp/nqKTeQiolxgt4Khvv6s61JDXzHBupt3bqJo4/E3H0/3NQM+E4gHrSlYLxLgVV tksw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=pezoiC3bd4O/h/75aqFJKkzwyd2Qs6/b9qlYox1d2Ek=; b=1A8gs9m6ib/LY3mFBNE54/PLgDADZ5VepodVX+Sey2RDv4KD4AJzSG0/ZSex6UttyI 8jKoFRgdITfpgyk2QRVyw1ZoiycZTt2YMGRwXrUVo4TcDpiYp7yEsY5xnaiAj2KTKHrV 0qWYVj457QFx4zTGL58gulp0Q/ui5JnEUnMeQS2Z6AHxkZMK1uXTO95asiTZj7/9G0E5 V8F5UkTkstXiaTp6AEEUdwyWyCSPLrzFLsXT5n2p9LicZ6YXUqt4+JBqXBsBTPaqOMVD Ou66hbp2SjsyXI70ufH3UcyTeQSSTGdjw/UNMtmbQqQg71LrN+KZqQ0HKVHhLzL8zpRT PlyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=0aoMRj9c; 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=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o21-v6si1604723pgl.165.2018.07.26.08.41.59; Thu, 26 Jul 2018 08:42:14 -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; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=0aoMRj9c; 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=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731831AbeGZQ5N (ORCPT + 99 others); Thu, 26 Jul 2018 12:57:13 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:47840 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730298AbeGZQ5N (ORCPT ); Thu, 26 Jul 2018 12:57:13 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w6QFXuoH141008 for ; Thu, 26 Jul 2018 15:39:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : references : in-reply-to : from : date : message-id : subject : to : cc : content-type; s=corp-2018-07-02; bh=pezoiC3bd4O/h/75aqFJKkzwyd2Qs6/b9qlYox1d2Ek=; b=0aoMRj9cnM6xwnbR8VC4QI557vR/N8jB/B1bHTApffLAg7E5tS7ticXsNbNGCBp+lE/B bsVs060MkRNX/pC15RKe1qB3WehAt+2kBTG5pA+JwsfHW1E94SZFqXb4PF6r43t/06jg ZEuVfo1Pej6HS7uy6DN76aa63lVAFlMIaEHIouUBFE/9RyY/DYaXk9wVB8Hu8AA5MEmR Cw8Q3lxrxCbptDYupy6tmQQj9P2foS2hHZpL+z4/oz/POBYzyk3/s9Qf+Nqf3eIbVa/S rOReVVRoZ9am/r4lf3RmZRN2mkU1IupBbweXXA3WA96zXI4zT+xiRMv7uJMtqgt1n0nu Eg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2kbwfq3n7n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 26 Jul 2018 15:39:49 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w6QFdl2V004777 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 26 Jul 2018 15:39:48 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w6QFdlBn001718 for ; Thu, 26 Jul 2018 15:39:47 GMT Received: from mail-oi0-f44.google.com (/209.85.218.44) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 26 Jul 2018 08:39:47 -0700 Received: by mail-oi0-f44.google.com with SMTP id n21-v6so3733777oig.3 for ; Thu, 26 Jul 2018 08:39:47 -0700 (PDT) X-Gm-Message-State: AOUpUlF4anGVhx6t6ZTSmAbiC4zcvleDhMjj8pvj7zyUp4AVL6/w2Pa+ t+WEYqnZoHuI5KhZL5D8Bh+swR5z2nGCLiOb6ao= X-Received: by 2002:aca:3bc2:: with SMTP id i185-v6mr2668243oia.156.1532619580246; Thu, 26 Jul 2018 08:39:40 -0700 (PDT) MIME-Version: 1.0 References: <20180724235520.10200-1-pasha.tatashin@oracle.com> <20180724235520.10200-3-pasha.tatashin@oracle.com> <20180724183142.d20798b43fd1215f6165649c@linux-foundation.org> <20180725143007.25d5bff352872aba90ca731b@linux-foundation.org> In-Reply-To: <20180725143007.25d5bff352872aba90ca731b@linux-foundation.org> From: Pavel Tatashin Date: Thu, 26 Jul 2018 11:39:04 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/3] mm: calculate deferred pages after skipping mirrored memory To: Andrew Morton Cc: Steven Sistare , Daniel Jordan , LKML , kirill.shutemov@linux.intel.com, Michal Hocko , Linux Memory Management List , dan.j.williams@intel.com, jack@suse.cz, jglisse@redhat.com, Souptick Joarder , bhe@redhat.com, gregkh@linuxfoundation.org, Vlastimil Babka , Wei Yang , dave.hansen@intel.com, rientjes@google.com, mingo@kernel.org, osalvador@techadventures.net, abdhalee@linux.vnet.ibm.com, mpe@ellerman.id.au Content-Type: text/plain; charset="UTF-8" X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8965 signatures=668706 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807260162 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 25, 2018 at 5:30 PM Andrew Morton wrote: > > On Tue, 24 Jul 2018 21:46:25 -0400 Pavel Tatashin wrote: > > > > > +static inline bool defer_init(int nid, unsigned long pfn, unsigned long end_pfn) > > > > { > > > > + static unsigned long prev_end_pfn, nr_initialised; > > > > > > So answer me quick, what happens with a static variable in an inlined > > > function? Is there one copy kernel-wide? One copy per invocation > > > site? One copy per compilation unit? > > > > > > Well I didn't know so I wrote a little test. One copy per compilation > > > unit (.o file), it appears. > > > > > > It's OK in this case because the function is in .c (and has only one > > > call site). But if someone moves it into a header and uses it from a > > > different .c file, they have problems. > > > > > > So it's dangerous, and poor practice. I'll make this non-static > > > __meminit. > > > > I agree, it should not be moved to header it is dangerous. > > > > But, on the other hand this is a hot-path. memmap_init_zone() might > > need to go through billions of struct pages early in boot, and I did > > not want us to waste time on function calls. With defer_init() this is > > not a problem, because if CONFIG_DEFERRED_STRUCT_PAGE_INIT is set > > memmap_init_zone() won't have much work to do, but for > > overlap_memmap_init() this is a problem, especially because I expect > > compiler to optimize the pfn dereference usage in inline function. > > Well. The compiler will just go and inline defer_init() anwyay - it > has a single callsite and is in the same __meminint section as its > calling function. My gcc-7.2.0 does this. Marking it noninline > __meminit is basically syntactic fluff designed to encourage people to > think twice. Makes sense. I will do the change in the next version of the patches. > > > > > > > --- a/mm/page_alloc.c~mm-calculate-deferred-pages-after-skipping-mirrored-memory-fix > > > +++ a/mm/page_alloc.c > > > @@ -309,7 +309,8 @@ static inline bool __meminit early_page_ > > > * Returns true when the remaining initialisation should be deferred until > > > * later in the boot cycle when it can be parallelised. > > > */ > > > -static inline bool defer_init(int nid, unsigned long pfn, unsigned long end_pfn) > > > +static bool __meminit > > > +defer_init(int nid, unsigned long pfn, unsigned long end_pfn) > > > { > > > static unsigned long prev_end_pfn, nr_initialised; > > > > > > > > > Also, what locking protects these statics? Our knowledge that this > > > code is single-threaded, presumably? > > > > Correct, this is called only from "context == MEMMAP_EARLY", way > > before smp_init(). > > Might be worth a little comment to put readers minds at ease. Will add it. Thank you, Pavel