From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F173C433ED for ; Fri, 9 Apr 2021 12:43:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 16BBA610E7 for ; Fri, 9 Apr 2021 12:43:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 16BBA610E7 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 874046B0092; Fri, 9 Apr 2021 08:43:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7FD538D0002; Fri, 9 Apr 2021 08:43:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 677D46B0095; Fri, 9 Apr 2021 08:43:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0237.hostedemail.com [216.40.44.237]) by kanga.kvack.org (Postfix) with ESMTP id 48F1C6B0092 for ; Fri, 9 Apr 2021 08:43:00 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id EFC9B184906C2 for ; Fri, 9 Apr 2021 12:42:59 +0000 (UTC) X-FDA: 78012793278.07.ABB8EB8 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf11.hostedemail.com (Postfix) with ESMTP id 55DD02000266 for ; Fri, 9 Apr 2021 12:42:53 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1617972178; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YiL8GIn+kNksZGX+sHZ8dtDnwl03BF0KcDznW8aXSqA=; b=UfUcXlLJ8zbFuZ+4eapJA8Cvjn/dHDzZs21SonEP/japaikGIw41zEGfTlkPMNA18t7Rpk S1ofdPXsp7dzaIZgCh1dtjD4bUettRcKarIIuy7BS3r1/pa9fu2qPqPkkuD8X3mndq9OlJ 7HxjCjK09MIBf1l2Qklpp6ucGdUaSaE= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 2C172AF4C; Fri, 9 Apr 2021 12:42:58 +0000 (UTC) Date: Fri, 9 Apr 2021 14:42:57 +0200 From: Michal Hocko To: Mel Gorman Cc: Andrew Morton , Linux-MM , LKML , Oscar Salvador , "Michael S. Tsirkin" , David Hildenbrand , Vlastimil Babka , Alexander Duyck , Minchan Kim Subject: Re: [PATCH] mm/memory_hotplug: Make unpopulated zones PCP structures unreachable during hot remove Message-ID: References: <20210409120957.GM3697@techsingularity.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210409120957.GM3697@techsingularity.net> X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 55DD02000266 X-Stat-Signature: 3chr15mi4c6haqwqjp7jfiihnka58ti8 Received-SPF: none (suse.com>: No applicable sender policy available) receiver=imf11; identity=mailfrom; envelope-from=""; helo=mx2.suse.de; client-ip=195.135.220.15 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1617972173-720180 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: On Fri 09-04-21 13:09:57, Mel Gorman wrote: > zone_pcp_reset allegedly protects against a race with drain_pages > using local_irq_save but this is bogus. local_irq_save only operates > on the local CPU. If memory hotplug is running on CPU A and drain_pages > is running on CPU B, disabling IRQs on CPU A does not affect CPU B and > offers no protection. Yes, the synchronization aspect is bogus indeed. > This patch reorders memory hotremove such that the PCP structures > relevant to the zone are no longer reachable by the time the structures > are freed. With this reordering, no protection is required to prevent > a use-after-free and the IRQs can be left enabled. zone_pcp_reset is > renamed to zone_pcp_destroy to make it clear that the per-cpu structures > are deleted when the function returns. Wouldn't it be much easier to simply not destroy/reset pcp of an empty zone at all? The whole point of this exercise seems to be described in 340175b7d14d5. setup_zone_pageset can check for an already allocated pcp and simply reinitialize it. -- Michal Hocko SUSE Labs