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=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 AE87CC5519F for ; Wed, 18 Nov 2020 04:53:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0FC0B2463F for ; Wed, 18 Nov 2020 04:53:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="Tie7eb5a" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0FC0B2463F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3465F6B0036; Tue, 17 Nov 2020 23:53:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2CF336B005C; Tue, 17 Nov 2020 23:53:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 197816B0068; Tue, 17 Nov 2020 23:53:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0206.hostedemail.com [216.40.44.206]) by kanga.kvack.org (Postfix) with ESMTP id DDFF86B0036 for ; Tue, 17 Nov 2020 23:53:04 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 6C2731EE6 for ; Wed, 18 Nov 2020 04:53:04 +0000 (UTC) X-FDA: 77496319488.27.tub65_410392727337 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin27.hostedemail.com (Postfix) with ESMTP id 4E1063D663 for ; Wed, 18 Nov 2020 04:53:04 +0000 (UTC) X-HE-Tag: tub65_410392727337 X-Filterd-Recvd-Size: 3353 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Wed, 18 Nov 2020 04:53:03 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 50EF92463B; Wed, 18 Nov 2020 04:53:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1605675182; bh=YCosJ2qYaKYkNcdNS2lsX13OGUTapFeLurPSXtSY+yk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Tie7eb5a7TGFHuXfQKFc18si/9EZtnUmgSFQYX4CGvs5aVPpW1/N6cLGDnv9rC6UC zxkxaptgjS5j619jNjOTbYBMfZK21CQSMde6I8vSErrktiKlLf8Ra7hO19t9nbYWD8 Z0U5Huazt/VSjcrl/OKncScPsDznNsmv5IAMZfx8= Date: Tue, 17 Nov 2020 20:53:01 -0800 From: Andrew Morton To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-mm@kvack.org, "Michael S . Tsirkin" , Wei Yang , Jason Wang , Pankaj Gupta , Michal Hocko , Oscar Salvador Subject: Re: [PATCH v2 27/29] mm/memory_hotplug: extend offline_and_remove_memory() to handle more than one memory block Message-Id: <20201117205301.bcef9773f3557a764d17b8df@linux-foundation.org> In-Reply-To: <20201112133815.13332-28-david@redhat.com> References: <20201112133815.13332-1-david@redhat.com> <20201112133815.13332-28-david@redhat.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 Thu, 12 Nov 2020 14:38:13 +0100 David Hildenbrand wrote: > virtio-mem soon wants to use offline_and_remove_memory() memory that > exceeds a single Linux memory block (memory_block_size_bytes()). Let's > remove that restriction. > > Let's remember the old state and try to restore that if anything goes > wrong. While re-onlining can, in general, fail, it's highly unlikely to > happen (usually only when a notifier fails to allocate memory, and these > are rather rare). > > This will be used by virtio-mem to offline+remove memory ranges that are > bigger than a single memory block - for example, with a device block > size of 1 GiB (e.g., gigantic pages in the hypervisor) and a Linux memory > block size of 128MB. > > While we could compress the state into 2 bit, using 8 bit is much > easier. > > This handling is similar, but different to acpi_scan_try_to_offline(): > > a) We don't try to offline twice. I am not sure if this CONFIG_MEMCG > optimization is still relevant - it should only apply to ZONE_NORMAL > (where we have no guarantees). If relevant, we can always add it. > > b) acpi_scan_try_to_offline() simply onlines all memory in case > something goes wrong. It doesn't restore previous online type. Let's do > that, so we won't overwrite what e.g., user space configured. > > ... > uint8_t is a bit of a mouthful. u8 is less typing ;) Doesn't matter. Acked-by: Andrew Morton