Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3629843imm; Mon, 10 Sep 2018 22:39:14 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbyOBdkxGWRkS6sC5ttFH01gNKhZELzDHam7MzPPw2yfjeb2SLh5FFDHDFglgtq3Is6O0Jg X-Received: by 2002:a17:902:be07:: with SMTP id r7-v6mr25006043pls.275.1536644354854; Mon, 10 Sep 2018 22:39:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536644354; cv=none; d=google.com; s=arc-20160816; b=hSdOwSIAkO33KKdcXsMEocRIPX+aOgt32YT0d8ANlsa5hd2rHYcg4sJZP6pJrHkQ5n pyvmPEhMIkuFjOgw6U30p5OTDa8Y98mFinFG44ZZVq1u2QESf0u0zgXsObqVMSndy7ZH A5vFgbSefRb4Z1ThVH0/4apK0Vb+ctH/xO/8Tw45EHXrp8BL+u9WzME81prkIPmEmFg2 C8fZRE1T5fncfPeCOnxQQdftrWQKgotZm/zu4DvrcdAL6t89L19e+DDOcc7sZJG7I3qH eccdu/KJYmgsZIY8UZzW7qTLRjrW42Uy8INYFTT3oBowOf0DEGA2lKFBdkoRnM5dd6Vp d6YQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=zM3eX3u5mJ8rJUOu5xmJHCZxTwzjqsaVd28sDT85h4Y=; b=IO1qSW9yy1io8UPL+ZafKl6IGnIcrQhJR0Nmg+dWpfqYakXFo0zmxudF5JVH0LiQec 8ScP8hlpqIX8Mg9knhmNKxBF3VWbgQtRajo5xJg3AoaZYFbMyQOdBcNJZqMvLhK/q2ij 2bp8t0CJyx0pqYN/ApOM/ZZ6W42k2plmFGXy/YS2l9lUME6/JBJLcRvQwLHxT3eS3A76 E0smVuC3q6cQHlMNwxtMFj6UodbXebinAe8zfXdb3gnh42QTeHjZJslA7KZm40kucnpL jF4LDI3p6SXnxnz7kNJ1Pb9N+JuQ/ugcyi9c/koiKHqxrh4hOxpVsZrONkSYN4BWF+TS LxYA== 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 h69-v6si19044810pfc.121.2018.09.10.22.38.59; Mon, 10 Sep 2018 22:39: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; 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 S1727645AbeIKKeL (ORCPT + 99 others); Tue, 11 Sep 2018 06:34:11 -0400 Received: from mga17.intel.com ([192.55.52.151]:62541 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727491AbeIKKeL (ORCPT ); Tue, 11 Sep 2018 06:34:11 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Sep 2018 22:36:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,359,1531810800"; d="scan'208";a="262426337" Received: from aaronlu.sh.intel.com ([10.239.159.44]) by fmsmga006.fm.intel.com with ESMTP; 10 Sep 2018 22:36:34 -0700 From: Aaron Lu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Andrew Morton , Dave Hansen , Michal Hocko , Vlastimil Babka , Mel Gorman , Matthew Wilcox , Daniel Jordan , Tariq Toukan , Yosef Lev , Jesper Dangaard Brouer Subject: [RFC PATCH 6/9] use atomic for free_area[order].nr_free Date: Tue, 11 Sep 2018 13:36:13 +0800 Message-Id: <20180911053616.6894-7-aaron.lu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180911053616.6894-1-aaron.lu@intel.com> References: <20180911053616.6894-1-aaron.lu@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since we will make free path run concurrently, free_area[].nr_free has to be atomic. Signed-off-by: Aaron Lu --- include/linux/mmzone.h | 2 +- mm/page_alloc.c | 12 ++++++------ mm/vmstat.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 84cfa56e2d19..e66b8c63d5d1 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -95,7 +95,7 @@ extern int page_group_by_mobility_disabled; struct free_area { struct list_head free_list[MIGRATE_TYPES]; - unsigned long nr_free; + atomic_long_t nr_free; }; struct pglist_data; diff --git a/mm/page_alloc.c b/mm/page_alloc.c index d0b954783f1d..dff3edc60d71 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -701,7 +701,7 @@ static inline void add_to_buddy_common(struct page *page, struct zone *zone, unsigned int order) { set_page_order(page, order); - zone->free_area[order].nr_free++; + atomic_long_inc(&zone->free_area[order].nr_free); } static inline void add_to_buddy_head(struct page *page, struct zone *zone, @@ -728,7 +728,7 @@ static inline void remove_from_buddy(struct page *page, struct zone *zone, unsigned int order) { list_del(&page->lru); - zone->free_area[order].nr_free--; + atomic_long_dec(&zone->free_area[order].nr_free); rmv_page_order(page); } @@ -2225,7 +2225,7 @@ int find_suitable_fallback(struct free_area *area, unsigned int order, int i; int fallback_mt; - if (area->nr_free == 0) + if (atomic_long_read(&area->nr_free) == 0) return -1; *can_steal = false; @@ -3178,7 +3178,7 @@ bool __zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark, struct free_area *area = &z->free_area[o]; int mt; - if (!area->nr_free) + if (atomic_long_read(&area->nr_free) == 0) continue; for (mt = 0; mt < MIGRATE_PCPTYPES; mt++) { @@ -5029,7 +5029,7 @@ void show_free_areas(unsigned int filter, nodemask_t *nodemask) struct free_area *area = &zone->free_area[order]; int type; - nr[order] = area->nr_free; + nr[order] = atomic_long_read(&area->nr_free); total += nr[order] << order; types[order] = 0; @@ -5562,7 +5562,7 @@ static void __meminit zone_init_free_lists(struct zone *zone) unsigned int order, t; for_each_migratetype_order(order, t) { INIT_LIST_HEAD(&zone->free_area[order].free_list[t]); - zone->free_area[order].nr_free = 0; + atomic_long_set(&zone->free_area[order].nr_free, 0); } } diff --git a/mm/vmstat.c b/mm/vmstat.c index 06d79271a8ae..c1985550bb9f 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1030,7 +1030,7 @@ static void fill_contig_page_info(struct zone *zone, unsigned long blocks; /* Count number of free blocks */ - blocks = zone->free_area[order].nr_free; + blocks = atomic_long_read(&zone->free_area[order].nr_free); info->free_blocks_total += blocks; /* Count free base pages */ @@ -1353,7 +1353,7 @@ static void frag_show_print(struct seq_file *m, pg_data_t *pgdat, seq_printf(m, "Node %d, zone %8s ", pgdat->node_id, zone->name); for (order = 0; order < MAX_ORDER; ++order) - seq_printf(m, "%6lu ", zone->free_area[order].nr_free); + seq_printf(m, "%6lu ", atomic_long_read(&zone->free_area[order].nr_free)); seq_putc(m, '\n'); } -- 2.17.1