Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp593498pxk; Thu, 3 Sep 2020 07:49:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhPEw++rHzU4bniNIxbNBhCbcYKURvNdDsEifuHjodl0X40BODCqWlhcNy4vdVelbGJ2qU X-Received: by 2002:a17:906:d97b:: with SMTP id rp27mr2668092ejb.18.1599144542631; Thu, 03 Sep 2020 07:49:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599144542; cv=none; d=google.com; s=arc-20160816; b=ss4xARrAU3ufiYcT2IY9qhqhB3ikmwu4XWqG0MKaEcsMwxZ+esisYebOb6xhvz+9e2 1rHt9Yuyx3PXzGMDvmeH1RHYb7a3/gNzLJ9UJV9VrtWnbyQpZEeaGCJuyiEeX+82G13r aXcdwi51ZNkhV01KFwTuMtU5Kyoo6zIua1QIDDbb5gs19PLGm1EBmvVS/I620sN5MyNv GRXAg3KcVC2cciGHgz4lJrKRBFFsj2hbHX3lKJP8VPuE+EC61gUiGtCRHLahREaFP8yS irHMsGNnLDzX0EBRdWRtfkn9hTVB9/H/19+iZFY0yFqAglAWNGJ18pjZkVJ/SuUm+dpn Bg2Q== 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:references:to:subject; bh=ntYdzSm/G46SwPG+3r/vMbsYA376/MgnvLZKYoMzP7w=; b=DK1Ca+D+effXcqUCawllpSO1Y7waoXzbZyqYjMHHSKHR0Zw/xZVPq7e+E3G3zCRwqe UAoNg8ORPnWKLFCnykXj+AZEZ6cfCF4nsHhUd/MLkyY/dtaQZnhPcyXS7UdK0kurlm2Y +zev4VA3nsWCGvIpHJzgWGpvdBdimjkGy6eqwyifEiVlitG0YHQgLrWKqwpG3Tdc2Lqx uW4x2/EMIAzUEX4A0wBZm20uYnSf/WvTViNT3zgeelLEvIr52HooL/72wfQqh95X00Gs 2ckUvDFSJvpna0UWqIWEzalm0qC7CM81rtGxUDcSZ4wyBhYKxYgwagRG2Bwv9ETFOAkg MJtg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u20si1807698edy.509.2020.09.03.07.48.40; Thu, 03 Sep 2020 07:49:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729265AbgICOsC (ORCPT + 99 others); Thu, 3 Sep 2020 10:48:02 -0400 Received: from mx2.suse.de ([195.135.220.15]:38054 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729184AbgICOXt (ORCPT ); Thu, 3 Sep 2020 10:23:49 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 9843DAB91; Thu, 3 Sep 2020 13:50:21 +0000 (UTC) Subject: Re: [PATCH] mm/memory_hotplug: drain per-cpu pages again during memory offline To: Pavel Tatashin , linux-kernel@vger.kernel.org, akpm@linux-foundation.org, mhocko@suse.com, linux-mm@kvack.org References: <20200901124615.137200-1-pasha.tatashin@soleen.com> From: Vlastimil Babka Message-ID: <49d977ed-549a-8810-fb71-cf47b9f81f27@suse.cz> Date: Thu, 3 Sep 2020 15:50:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <20200901124615.137200-1-pasha.tatashin@soleen.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 9/1/20 2:46 PM, Pavel Tatashin wrote: > There is a race during page offline that can lead to infinite loop: > a page never ends up on a buddy list and __offline_pages() keeps > retrying infinitely or until a termination signal is received. > > Thread#1 - a new process: > > load_elf_binary > begin_new_exec > exec_mmap > mmput > exit_mmap > tlb_finish_mmu > tlb_flush_mmu > release_pages > free_unref_page_list > free_unref_page_prepare > set_pcppage_migratetype(page, migratetype); > // Set page->index migration type below MIGRATE_PCPTYPES > > Thread#2 - hot-removes memory > __offline_pages > start_isolate_page_range > set_migratetype_isolate > set_pageblock_migratetype(page, MIGRATE_ISOLATE); > Set migration type to MIGRATE_ISOLATE-> set > drain_all_pages(zone); > // drain per-cpu page lists to buddy allocator. > > Thread#1 - continue > free_unref_page_commit > migratetype = get_pcppage_migratetype(page); > // get old migration type > list_add(&page->lru, &pcp->lists[migratetype]); > // add new page to already drained pcp list > > Thread#2 > Never drains pcp again, and therefore gets stuck in the loop. > > The fix is to try to drain per-cpu lists again after > check_pages_isolated_cb() fails. > > Signed-off-by: Pavel Tatashin > Cc: stable@vger.kernel.org Fixes: ? Acked-by: Vlastimil Babka Thanks.