Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1734703ybg; Sat, 19 Oct 2019 01:21:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/CMNtTqdMK1Y40xHcJci3DCp2JBJceDKcT+YI25TM0JNR3XORoLaMFdSIJxVslUxn85wO X-Received: by 2002:a50:b723:: with SMTP id g32mr14048612ede.13.1571473269936; Sat, 19 Oct 2019 01:21:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571473269; cv=none; d=google.com; s=arc-20160816; b=VNJFbAFA76H4hO7WXsdAxYiX2gJlV2EXd7PqqTpMcyAx2/UgfWaEsqEAx/YXIb1Yeh hkFkI7lFWtbrz6utoSbUWEFqxl1J/U8+osIVpA3l4BYLghuH/WjsGCh739lBURmXpxkl rR0CJllEfVr1Yonz94iuaVYRnqcebenjXs329o0TAmMS8EnXut6itSqSmPFWWgj3oRUa hKsdIJ4IRjRUV7T6qa4yxI0Q043w24lNX72E/hAoOHmimCe99dXNuT2wBybZ2x2S/5X7 yU0gMF0ilpfDsSqquXWlWs/MO+z8FwRSMQTg0F+bEDt8/qr/zmyLbtGBUsibDl2Cb0CK /jIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=mmt5RpJv1vAiW82a/zU2L+rpJDn5a1HplcXho5lyQPw=; b=I4TPIGLfCyGMVlfxlaqfCqw4Fw2oZVoEjHhKZoy31Y0RQvmYjP5JboPyeIsx2AHDub 6D5bo2BO/rC9bJKWnfcjEDMZMBOn1M/6gztxKRWHdDlzzZP/PoeVDRU1obfD44213K47 1S5yloOn1HcDd8zbmQbxFWcb/tpmO/se0PGpsezflTS4dIju/qYGpiTlFFJEgcIjp+oR vPQsbowTwZl/VYAxfc5BpGuuQsB3b+1DkhbDtUkZrc/VXFACh+zKqqLnXZ1XdmppBb/6 3CYluOhDDH4s7ib306eaaEFvyfKfJD7EUeK6nQmzbXfHF8bjbnDiZk/4f75E6Vw6l1Jt v9Xg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p39si5876090eda.416.2019.10.19.01.20.47; Sat, 19 Oct 2019 01:21:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407745AbfJRMGV (ORCPT + 99 others); Fri, 18 Oct 2019 08:06:21 -0400 Received: from mx2.suse.de ([195.135.220.15]:40798 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2394320AbfJRMGV (ORCPT ); Fri, 18 Oct 2019 08:06:21 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 04FC1B537; Fri, 18 Oct 2019 12:06:18 +0000 (UTC) Date: Fri, 18 Oct 2019 14:06:15 +0200 From: Michal Hocko To: Oscar Salvador Cc: n-horiguchi@ah.jp.nec.com, mike.kravetz@oracle.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v2 10/16] mm,hwpoison: Rework soft offline for free pages Message-ID: <20191018120615.GM5017@dhcp22.suse.cz> References: <20191017142123.24245-1-osalvador@suse.de> <20191017142123.24245-11-osalvador@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191017142123.24245-11-osalvador@suse.de> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 17-10-19 16:21:17, Oscar Salvador wrote: [...] > +bool take_page_off_buddy(struct page *page) > + { > + struct zone *zone = page_zone(page); > + unsigned long pfn = page_to_pfn(page); > + unsigned long flags; > + unsigned int order; > + bool ret = false; > + > + spin_lock_irqsave(&zone->lock, flags); What prevents the page to be allocated in the meantime? Also what about free pages on the pcp lists? Also the page could be gone by the time you have reached here. > + for (order = 0; order < MAX_ORDER; order++) { > + struct page *page_head = page - (pfn & ((1 << order) - 1)); > + int buddy_order = page_order(page_head); > + struct free_area *area = &(zone->free_area[buddy_order]); > + > + if (PageBuddy(page_head) && buddy_order >= order) { > + unsigned long pfn_head = page_to_pfn(page_head); > + int migratetype = get_pfnblock_migratetype(page_head, > + pfn_head); > + > + del_page_from_free_area(page_head, area); > + break_down_buddy_pages(zone, page_head, page, 0, > + buddy_order, area, migratetype); > + ret = true; > + break; > + } > + } > + spin_unlock_irqrestore(&zone->lock, flags); > + return ret; > + } > + > +/* > * Set PG_hwpoison flag if a given page is confirmed to be a free page. This > * test is performed under the zone lock to prevent a race against page > * allocation. > -- > 2.12.3 -- Michal Hocko SUSE Labs