From patchwork Tue Sep 11 05:36:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lu X-Patchwork-Id: 10595071 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D14A2921 for ; Tue, 11 Sep 2018 05:36:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0208292A8 for ; Tue, 11 Sep 2018 05:36:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B4522292B6; Tue, 11 Sep 2018 05:36:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3BA4E292A8 for ; Tue, 11 Sep 2018 05:36:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ECC7A8E0009; Tue, 11 Sep 2018 01:36:38 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E54CB8E0001; Tue, 11 Sep 2018 01:36:38 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D1FB58E0009; Tue, 11 Sep 2018 01:36:38 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by kanga.kvack.org (Postfix) with ESMTP id 90CC28E0001 for ; Tue, 11 Sep 2018 01:36:38 -0400 (EDT) Received: by mail-pl1-f200.google.com with SMTP id w18-v6so11074340plp.3 for ; Mon, 10 Sep 2018 22:36:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=zM3eX3u5mJ8rJUOu5xmJHCZxTwzjqsaVd28sDT85h4Y=; b=YvyLYsUGSnn30OdDLrRuH9wpmG8Vjtg4VacNUQ7yP3SzkC8GzWxs2brMlI2ryJ9hR2 QdcBV99xOwNa65bx4BXEz4Ztv/jkeTAUQDUeh6snn8MIDrkKaMLnbcvquT50FYAC3bfO V21hVPGf5ANkodrmCEhiJ5ovjaJZKCBD1l+5BKKS9De64hMsjRUFL6uw6a7B/PFpIJII kDoOdVWDr+djhXH3MnpZBuX3lCc4PMpt8J2xEu0XPXZ2dAym0PZWxIoQtVhArlzzpe3M 0eYpexFPSVAfK2LoruN8NUVH/Evs+Ft9pP1RwZ/a0MMPF8CpWw8E9HCn/EE8mGO/lovg YKHQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of aaron.lu@intel.com designates 192.55.52.93 as permitted sender) smtp.mailfrom=aaron.lu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: APzg51D4pyyLOw0IfPBUV3inv0V7/GMSDE3qyJ4eYQqGLq7ZlqhNSSFo HMVMV6PEyaGXZiaqz8NW+wvsGIWx8mYSl7LZB4HwQKf0bOAfOZS9MixlAm+w2yq+5/EN8Em9cfX E1WKYoFnkApzHcMkNO9vaso3fuZWHjkVXBybPmdvGCsaEocuo+AGuUgvjkUAn/ZVBLg== X-Received: by 2002:a17:902:8605:: with SMTP id f5-v6mr24876594plo.271.1536644198270; Mon, 10 Sep 2018 22:36:38 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZmH1szMT+eIvdf9iGnr5+Z6NHPI+NKEal+UMXakWE30+/3VYN5tj138kZ8fIe7R5R0oawB X-Received: by 2002:a17:902:8605:: with SMTP id f5-v6mr24876552plo.271.1536644197512; Mon, 10 Sep 2018 22:36:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536644197; cv=none; d=google.com; s=arc-20160816; b=j0HJQ7t6iHu5CPmLlxqoSo6/QkTQX95JYlL9DgWdAeaBhGleWV460Rl6MTcbgETo1E 4I0D+bd09CiE2i23hcFkRjT2rW8/LiHZJdQ0pJ9MLDaPBMFei2Dwmo6/S42KSB+HnGXx h+crcxuVNB6gfD0jNhhAalH9j/v3hoiDNKE+9/nw0ryvJGUVJpjvqDzf8tJiJ+3Zdjnh AW/JTB9P0XivpSunCA9k3r8ZVZeGXF8W9L2YPSDT0/5LzlpgX6i2d1k3h83XQgv7LhUm 3l3tspsca0jdKaIsMpOAfDYoWvsuBCDPzqPm3HwyssSAPVz5B5xc/y2Vt3LL4+Lsdf+z elsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=zM3eX3u5mJ8rJUOu5xmJHCZxTwzjqsaVd28sDT85h4Y=; b=WVPMEgJRrvy/7Xr+RJ/CFYRxFs95QGBxRixx4r3HVWd4afW9Nz52OVkR0ChnmwoCXS FUgzcL6Dq0a4vJox6W9DCkA5pBJ23uEkNPMz/QuGtUO7bwDS4zLHJ482oJlNfN+4CF/p up9JUD4Kd9NsAr9IYqyOR7ocJeNlPS3UGCvw7WBOGAnBXcw6tJ+R41/3Rs8J8mOapk0q tL4e01hhI8MI2kCUp4dpRxSWBqoEmhJEn8WOnLdTxwiZtnw+JWBKk1izCUol1i6mVAtB Z2KWE5hyeDJPCJMBAPs4+Ngj63O4aLsPyumkXB0odezyYLuNs4ErwUF4jgGjAais235j FNYg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of aaron.lu@intel.com designates 192.55.52.93 as permitted sender) smtp.mailfrom=aaron.lu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga11.intel.com (mga11.intel.com. [192.55.52.93]) by mx.google.com with ESMTPS id c19-v6si20646945pfc.18.2018.09.10.22.36.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Sep 2018 22:36:37 -0700 (PDT) Received-SPF: pass (google.com: domain of aaron.lu@intel.com designates 192.55.52.93 as permitted sender) client-ip=192.55.52.93; Authentication-Results: mx.google.com; spf=pass (google.com: domain of aaron.lu@intel.com designates 192.55.52.93 as permitted sender) smtp.mailfrom=aaron.lu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.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> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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'); }