Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1318372pxf; Fri, 9 Apr 2021 05:44:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1XTFVwQ2//rZhOM3lJLfEFfFNpHNQ4/gzn+Q2bCLhgsY09SRAIaPHmFZlLW+GJ4neh0zT X-Received: by 2002:a17:90b:8c3:: with SMTP id ds3mr13800696pjb.71.1617972258912; Fri, 09 Apr 2021 05:44:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617972258; cv=none; d=google.com; s=arc-20160816; b=Ykiyz/MnONBKAzRgdD/GUAsl7qvqT/051YjaLCS23KEKHdGVg+8CKbdxjNWK3bwlFO ebTKfkRqHqyh0b9uAAGiG1eQfriax9bbBM1rkgWF/YtpYSo0UA30eeaVfyYbuDtHA2pg +dkzy/j/Dbz2Gz3cmttZI7/kozJ7MBXbDpbJFy9WhU++O7GcaTWIGFTixxN1EJpSZygH bhqslpZDvLmgRudG4JIob2n7+CtzS2GZqcv9zeciZ3/OaYWxZiPHvRds83bX3k62+PaF wIuyDtHFIFVbiSV/bMT7T+E5W/RRW5eA4RcwRbY3IN+K1vTL+hY06TQGLwQjeWwYLwAE 6p6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=YiL8GIn+kNksZGX+sHZ8dtDnwl03BF0KcDznW8aXSqA=; b=Rs4vm/680c2YHy2dltF2yKIvo4KifAA5ApWuYQr03O1q2yBbTItQ2n9VSZaQ2ooOOK 0kjOCdqdkTaWOMWyNNb4DvbGgXMGBl4IWb/a1NA9Uplf3FvXzF93psqifjOYKXB0QlEp lJgNE/jed6cN0xBrGQj2luY2Je2EixBY0TpWO8cUoA68ReQlVAxXoe6jP2YBnsiOGEJ9 BTHYFcwoli0kQRrfLjllhMdNyKP3Z+zexnhjjpks/jr/Au18IBgTRen+xTTg1mC3q6gQ n+QWKNwmvrTw6eNTYKPfGqdghZUDSu9/9QFu7dBX0XT2RIHcC2E/GTN+PZbb8GXVQVQo fnuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=UfUcXlLJ; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 17si2840608plj.162.2021.04.09.05.44.06; Fri, 09 Apr 2021 05:44:18 -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; dkim=pass header.i=@suse.com header.s=susede1 header.b=UfUcXlLJ; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231756AbhDIMnO (ORCPT + 99 others); Fri, 9 Apr 2021 08:43:14 -0400 Received: from mx2.suse.de ([195.135.220.15]:33012 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231127AbhDIMnM (ORCPT ); Fri, 9 Apr 2021 08:43:12 -0400 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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