Received: by 10.213.65.68 with SMTP id h4csp185240imn; Mon, 12 Mar 2018 10:33:57 -0700 (PDT) X-Google-Smtp-Source: AG47ELsQTRGWbtOWBNaYjHgDswF9w5VfZ00kHWwBkhn6K34TG7o/MMeZMXwScyZb8TT1agbDqRZc X-Received: by 2002:a17:902:70cb:: with SMTP id l11-v6mr8778373plt.192.1520876037192; Mon, 12 Mar 2018 10:33:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520876037; cv=none; d=google.com; s=arc-20160816; b=cjvCe9Q0Ia6MHgKEr38NiTE+ephnjpOWjUNNFb4qo8xYnGSmFMJoc7fg8B6qaAlbVq 93JbHrNj77B1exFRdb8/Lc+ZKG61UnGO9Me4LjTs9Q8vJKUzJ9ReWvJoxWQ12MqRf8PU ws7Dnxzh3Wmq+qsJmA7PfEwTppRiG4YZ4kZVGE9ivpQgjtmY+PDm1FfmiK+1co9Frkql 7NO3WmGC6AOKa2zr6CS+TQMosWBnIBQaGE5fwkBZtHnpWLJ9bFVFTF0mqI0K3OzK8h9s zFLtl6DmnwHljniCunpWGtDv4kHzR7WCBDFi/oRUk0HKkLSCWsCEGNPF0HlUvgin7B6n 8FTQ== 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:cc:references:to:subject:arc-authentication-results; bh=Iptf9vcuNXh5QwPcY7j5socsEKJ8gwf+ZwkjXNZ+9ZI=; b=jcUmTdy6PKsoWxUTnplphy/T5my2mPBtPX95v5it9KQ31+ARkJskcvdjkhBTVlZ2Tb 3E+GYNX5yakMGUswC03MJSv/7FLMzbJQFgzSeuDB1KgXdoE17j2iSUpmWhCx/x3gOxY/ 97Csfbu49CCsgmew2LuCeR6P9QXji06LPsoF4tbpXImdYzD42BSB+9DFozQhCB9YIPLz bJDX9sApgOEDL5kI2jMNg7ptCa5KuCiUhOfCZBuW176c1utOd+a7jhe93F8Wob14luAl 4n3rRxCSxfMzY0W2W71HE9x+uY+8/KlmXMubS2XK0TTwd3UCGLah+4wqqrM/8jOs8SLG XpPQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k11-v6si6400828pll.391.2018.03.12.10.33.42; Mon, 12 Mar 2018 10:33:57 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932628AbeCLRcg (ORCPT + 99 others); Mon, 12 Mar 2018 13:32:36 -0400 Received: from mga12.intel.com ([192.55.52.136]:59504 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932231AbeCLRcf (ORCPT ); Mon, 12 Mar 2018 13:32:35 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Mar 2018 10:32:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,462,1515484800"; d="scan'208";a="36662994" Received: from bdomingu-mobl.amr.corp.intel.com (HELO [10.254.82.81]) ([10.254.82.81]) by fmsmga004.fm.intel.com with ESMTP; 12 Mar 2018 10:32:34 -0700 Subject: Re: [PATCH v4 3/3 update] mm/free_pcppages_bulk: prefetch buddy while not holding lock To: Aaron Lu , Andrew Morton References: <20180301062845.26038-1-aaron.lu@intel.com> <20180301062845.26038-4-aaron.lu@intel.com> <20180301160950.b561d6b8b561217bad511229@linux-foundation.org> <20180302082756.GC6356@intel.com> <20180309082431.GB30868@intel.com> Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Kemi Wang , Tim Chen , Andi Kleen , Michal Hocko , Vlastimil Babka , Mel Gorman , Matthew Wilcox , David Rientjes From: Dave Hansen Message-ID: <988ce376-bdc4-0989-5133-612bfa3f7c45@intel.com> Date: Mon, 12 Mar 2018 10:32:32 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180309082431.GB30868@intel.com> Content-Type: text/plain; charset=utf-8 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 On 03/09/2018 12:24 AM, Aaron Lu wrote: > + /* > + * We are going to put the page back to the global > + * pool, prefetch its buddy to speed up later access > + * under zone->lock. It is believed the overhead of > + * an additional test and calculating buddy_pfn here > + * can be offset by reduced memory latency later. To > + * avoid excessive prefetching due to large count, only > + * prefetch buddy for the last pcp->batch nr of pages. > + */ > + if (count > pcp->batch) > + continue; > + pfn = page_to_pfn(page); > + buddy_pfn = __find_buddy_pfn(pfn, 0); > + buddy = page + (buddy_pfn - pfn); > + prefetch(buddy); FWIW, I think this needs to go into a helper function. Is that possible? There's too much logic happening here. Also, 'count' going from batch_size->0 is totally non-obvious from the patch context. It makes this hunk look totally wrong by itself.