Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp726375imm; Wed, 17 Oct 2018 07:24:25 -0700 (PDT) X-Google-Smtp-Source: ACcGV62xpwdV+c+CA9oLeDMXC3cNcFyJXuuBmN+xScmSOiXiPRh7Vk9iNiJ5sn4ZzwZJj//MHv5Y X-Received: by 2002:a62:2fc1:: with SMTP id v184-v6mr26679460pfv.115.1539786265124; Wed, 17 Oct 2018 07:24:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539786265; cv=none; d=google.com; s=arc-20160816; b=eSJ/ksYVlMec8ojulp+FiFEeJzvvfqp7IO2xdMFySFR8ajZLAvyv4rAUiIsS7ymgb5 bKuW7XyitEDrce+AKj4qg57lz5cWMFQMpHQlg4+FsBvL/Mm9Ved/nnhWGfVJW84ghL2i X/hTd9lTCBr6hAoWY3nB84UVqduOZaHHa5tnuVR8h/jDLUDo4JcAIJJDpl1ZaO7Pdr+9 Us8f3GyelI1P6ce1iRVqodZmq1wJGkdFME2XnkTqdTo1X607Ttw7wPWlBLaiDFB8BnnM Efh+O7KmyVwsraSWHivBleDkvUMErW8fxlpnWPO//sTSryKI8J0dGQJ+pgTXeH1T2GPh G6RA== 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=cFzuceLTcXf2qxmCfRYN7bUEEubp6V6MWjBZu7YZlh0=; b=HW8YdzzCXjclD5xCmCCIpgJ6N3V7qWx3gMrq2R0OET7bWHZikbZ3UWvHvEdO4UX7t4 tAlVPmd7COTyXuu7g4/iNYQSaTD6Ie7cqKNkuoL8JWiIdTFU1xl9FS+5Yuuz4hOn5TtG UP7okjipU5V+I480+M+vfgK614xITzpmBG6meMF+Pg3GvkXuJGaBN/qxE4OViFW4knEU ZjerqFNu14j5vN7R4TrsaaVyNwgBIJA+20dkXhAm4kLVr/Z+ASN6pVtlsaODALR4ReYk rivhKVPnprMAdWiStVFJwTefB7jQauDAU9DmTNF1wlhaeUBCABf/xoganDrmgEhWSkLS 6EOg== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33-v6si14381815plu.316.2018.10.17.07.24.08; Wed, 17 Oct 2018 07:24:25 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727678AbeJQWT2 (ORCPT + 99 others); Wed, 17 Oct 2018 18:19:28 -0400 Received: from mga07.intel.com ([134.134.136.100]:12437 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727032AbeJQWT1 (ORCPT ); Wed, 17 Oct 2018 18:19:27 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Oct 2018 07:23:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,392,1534834800"; d="scan'208";a="89043679" Received: from aaronlu.sh.intel.com (HELO intel.com) ([10.239.159.44]) by FMSMGA003.fm.intel.com with ESMTP; 17 Oct 2018 07:23:28 -0700 Date: Wed, 17 Oct 2018 22:23:27 +0800 From: Aaron Lu To: Mel Gorman Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Huang Ying , Dave Hansen , Kemi Wang , Tim Chen , Andi Kleen , Michal Hocko , Vlastimil Babka , Matthew Wilcox , Daniel Jordan , Tariq Toukan , Jesper Dangaard Brouer Subject: Re: [RFC v4 PATCH 3/5] mm/rmqueue_bulk: alloc without touching individual page structure Message-ID: <20181017142327.GB9167@intel.com> References: <20181017063330.15384-1-aaron.lu@intel.com> <20181017063330.15384-4-aaron.lu@intel.com> <20181017112042.GK5819@techsingularity.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181017112042.GK5819@techsingularity.net> 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 On Wed, Oct 17, 2018 at 12:20:42PM +0100, Mel Gorman wrote: > On Wed, Oct 17, 2018 at 02:33:28PM +0800, Aaron Lu wrote: > > Profile on Intel Skylake server shows the most time consuming part > > under zone->lock on allocation path is accessing those to-be-returned > > page's "struct page" on the free_list inside zone->lock. One explanation > > is, different CPUs are releasing pages to the head of free_list and > > those page's 'struct page' may very well be cache cold for the allocating > > CPU when it grabs these pages from free_list' head. The purpose here > > is to avoid touching these pages one by one inside zone->lock. > > > > I didn't read this one in depth because it's somewhat ortogonal to the > lazy buddy merging which I think would benefit from being finalised and > ensuring that there are no reductions in high-order allocation success > rates. Pages being allocated on one CPU and freed on another is not that > unusual -- ping-pong workloads or things like netperf used to exhibit > this sort of pattern. > > However, this part stuck out > > > +static inline void zone_wait_cluster_alloc(struct zone *zone) > > +{ > > + while (atomic_read(&zone->cluster.in_progress)) > > + cpu_relax(); > > +} > > + > > RT has had problems with cpu_relax in the past but more importantly, as > this delay for parallel compactions and allocations of contig ranges, > we could be stuck here for very long periods of time with interrupts The longest possible time is one CPU accessing pcp->batch number cold cachelines. Reason: When zone_wait_cluster_alloc() is called, we already held zone lock so no more allocations are possible. Waiting in_progress to become zero means waiting any CPU that increased in_progress to finish processing their allocated pages. Since they will at most allocate pcp->batch pages and worse case are all these page structres are cache cold, so the longest wait time is one CPU accessing pcp->batch number cold cache lines. I have no idea if this time is too long though. > disabled. It gets even worse if it's from an interrupt context such as > jumbo frame allocation or a high-order slab allocation that is atomic. My understanding is atomic allocation won't trigger compaction, no? > These potentially large periods of time with interrupts disabled is very > hazardous. I see and agree, thanks for pointing this out. Hopefully, the above mentioned worst case time won't be regarded as unbound or too long. > It may be necessary to consider instead minimising the number > of struct page update when merging to PCP and then either increasing the > size of the PCP or allowing it to exceed pcp->high for short periods of > time to batch the struct page updates. I don't quite follow this part. It doesn't seem possible we can exceed pcp->high in allocation path, or are you talking about free path? And thanks a lot for the review!