Path: csiph.com!news.mixmin.net!news.unit0.net!news.panservice.it!diesel.cu.mi.it!bofh.it!news.nic.it!robomod From: Hugh Dickins Newsgroups: linux.kernel Subject: [PATCH 3/3] mm: delete unnecessary and unsafe init_tlb_ubc() Date: Sat, 24 Sep 2016 05:30:01 +0200 Message-ID: References: Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=xfOhMUYMIt5+I6A2431wQChZ+rpDb3hTzCOaBt2HMMI=; b=D1sdUgQbayPp3Twgw7uEQu9zljZCCmeVsDhj9CanqisBIC3ZhebFkcTVVByJJHufPg vDjI8t3vJSyp3YqOREQQSvRATXixS3blkUqhyvbStqjJ6UD3NSwl+sqozrDZHeKUS8Dk jvcaZ0zPWhrPVaRyV/GCKVmZPMNJWd+lcnn/BhOoN2TVam3ofd5mNn3dy3eLj4V3vaAV TBXcpxpGRxUKcOeuDzJCFP0BkiJOtzWo6PQzH3heohP9BcgPVZ4Ip2nzfxXteHSbUi9F feFLLBT+T49zmkUgoHXiLR7Vi6KNAxcpfuPmiLSHmtshMJc+AM86VPToI0KvYwqRyYne n8pQ== X-Google-Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=xfOhMUYMIt5+I6A2431wQChZ+rpDb3hTzCOaBt2HMMI=; b=KEXhCs695Q1nAKkIGGNC4RrZbVqHr+4wPcznK6RQhI1SgfsRak4cIBtgzVwfGq+v1q kD9wKs1co5bQ+LIIEk5ydmV5HsgWBo9iIDDwTc1DToW0TJljAqsgaKckGULQQfjEXcW+ 4mAkqpP1B53F1lks/iZeOcIfTautZR8GPS5OPng9j51kIlL0kiXywCLeZ/hEsO9ZVGNN EDHDgZasW8h95C08c9n4OhxbZGn7RzFoPKgbRuoThF5sn0bSvCFMf92N6WaNwsDkBbmo emQA6bQudekC3IT2F73z6R8yuUd+FcVff6h+7CZ0XjqIpFbYrfGile24XosjMJROF657 k2xg== X-Gm-Message-State: AE9vXwOnBkSZFnwWWtNirL/ax3zIwgAhA885TutZ1Au+zjhJX7pg4R5cYsicCmk8SeujdidB X-Received: by 10.202.76.7 with SMTP id z7mr13354464oia.56.1474687626279; Fri, 23 Sep 2016 20:27:06 -0700 (PDT) X-X-Sender: hugh@eggly.anvils User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: robomod@news.nic.it List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Approved: robomod@news.nic.it Lines: 60 Organization: linux.* mail to news gateway X-Original-Cc: Andrew Morton , Mel Gorman , linux-kernel@vger.kernel.org, linux-mm@kvack.org X-Original-Date: Fri, 23 Sep 2016 20:27:04 -0700 (PDT) X-Original-Message-ID: X-Original-References: X-Original-Sender: linux-kernel-owner@vger.kernel.org Xref: csiph.com linux.kernel:1490534 init_tlb_ubc() looked unnecessary to me: tlb_ubc is statically initialized with zeroes in the init_task, and copied from parent to child while it is quiescent in arch_dup_task_struct(); so I went to delete it. But inserted temporary debug WARN_ONs in place of init_tlb_ubc() to check that it was always empty at that point, and found them firing: because memcg reclaim can recurse into global reclaim (when allocating biosets for swapout in my case), and arrive back at the init_tlb_ubc() in shrink_node_memcg(). Resetting tlb_ubc.flush_required at that point is wrong: if the upper level needs a deferred TLB flush, but the lower level turns out not to, we miss a TLB flush. But fortunately, that's the only part of the protocol that does not nest: with the initialization removed, cpumask collects bits from upper and lower levels, and flushes TLB when needed. Fixes: 72b252aed506 ("mm: send one IPI per CPU to TLB flush all entries after unmapping pages") Signed-off-by: Hugh Dickins Acked-by: Mel Gorman Cc: stable@vger.kernel.org # 4.3+ --- mm/vmscan.c | 19 ------------------- 1 file changed, 19 deletions(-) --- 4.8-rc7/mm/vmscan.c 2016-09-05 16:42:52.496692429 -0700 +++ linux/mm/vmscan.c 2016-09-22 09:32:37.900894833 -0700 @@ -2303,23 +2303,6 @@ out: } } -#ifdef CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH -static void init_tlb_ubc(void) -{ - /* - * This deliberately does not clear the cpumask as it's expensive - * and unnecessary. If there happens to be data in there then the - * first SWAP_CLUSTER_MAX pages will send an unnecessary IPI and - * then will be cleared. - */ - current->tlb_ubc.flush_required = false; -} -#else -static inline void init_tlb_ubc(void) -{ -} -#endif /* CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH */ - /* * This is a basic per-node page freer. Used by both kswapd and direct reclaim. */ @@ -2355,8 +2338,6 @@ static void shrink_node_memcg(struct pgl scan_adjusted = (global_reclaim(sc) && !current_is_kswapd() && sc->priority == DEF_PRIORITY); - init_tlb_ubc(); - blk_start_plug(&plug); while (nr[LRU_INACTIVE_ANON] || nr[LRU_ACTIVE_FILE] || nr[LRU_INACTIVE_FILE]) {