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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 718E6C61D90 for ; Tue, 21 Nov 2023 19:24:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A544E6B00F5; Tue, 21 Nov 2023 14:24:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9DD166B015D; Tue, 21 Nov 2023 14:24:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 82F616B0173; Tue, 21 Nov 2023 14:24:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 548096B00F5 for ; Tue, 21 Nov 2023 14:24:58 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id F3170B5480 for ; Tue, 21 Nov 2023 19:24:57 +0000 (UTC) X-FDA: 81482939034.20.38D337E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf29.hostedemail.com (Postfix) with ESMTP id 9D94A120019 for ; Tue, 21 Nov 2023 19:24:55 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=b1zvYbO0; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700594695; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=hMEaDfpv+ikMyLmND0u4sTzvj6LLaz68SQyP8wyXNlM=; b=vyECnC1/flPzDDCC9TPgzRFMtiGItHI44Ma6jZKt+QCPwpCa/Tf97U6jPLDOgbfRiphQzy FQnfboCZc0pew2AuLqWzlaV5wKAm8gfbE1pCpP/iDRb4XkyP+bOQOciwHrp/L5wOwhjaXl C9wOG/9LfHM1jGpLoCxEiHSoXlEgnB0= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=b1zvYbO0; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700594695; a=rsa-sha256; cv=none; b=obRJpOp+yV3/jOPncQ9JxHv4JICCo64/nB80Cl3FKnkfeP60BFpB36OP4otthRWi0mPzeU rR1xopLJ1vyQGiDBqvkDJ/mLjCWynafmcMbPLojoN4XMr7uDR3HuDITgwnMiQS6sM5MT+P X9UcHy3xh1GnDIFnyOc+mDj5ZFghS+E= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700594694; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=hMEaDfpv+ikMyLmND0u4sTzvj6LLaz68SQyP8wyXNlM=; b=b1zvYbO04BeOJSGgzqJI09q9x8Gmw2YGPKJVFvb6S32C9NL5wsq994dWgQKVMiV1ACcKPE BO/GKClKFg0Xd2gNUGgtUkLQCmNevn+RhTA5b2UXKpyFs7DyCgl2maOJnSu+D/5ASGklV6 fYc6GfJMV2eRF2cUGq3ZG68/6akkfvU= Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-610-CT-oJMLbNmSvbuTYHcMEGw-1; Tue, 21 Nov 2023 14:24:52 -0500 X-MC-Unique: CT-oJMLbNmSvbuTYHcMEGw-1 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-50aa95b5f99so3607621e87.2 for ; Tue, 21 Nov 2023 11:24:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700594691; x=1701199491; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=hMEaDfpv+ikMyLmND0u4sTzvj6LLaz68SQyP8wyXNlM=; b=PWUUUcBCqEHg0fHRvOiljaf3AcRFRDRtybWWorSGlJB8yGdAwKzg3Y2gXJlX34QMWt HpGWKyW1W9dMSXKYrn1Npl93eLgu5cNmKHTX7mT9U7Xi/Tzeqy5Sh2L+xKoHe11++t2h nSKaRIqyXVd+KHE6dKc2su20r9vJ2myQVAMr1haXxIUHgUQAIbTfsOC3JwT+dkUeJWHu cwHbdHLx/VgNTlwQjkzVB37fz7uozFi/kOtZVOXWhs1Ojf0LIn/1Z3BUWXXWqf83u1B5 Fa9mm70w1d6VrZdSZlNyccL5sWrmhYJkVVuxsuCte6I5qYf4e+ioBq/hbFCWNNWr09/n +LWg== X-Gm-Message-State: AOJu0Yxdt2y5DQMxZAj6K38hg2kH6NThhdkEA6bcIhj57NNTf5nKf8jk OvVzJfYfNWANxeRwy4S02SYRWlrDU4kfOL7WzXTd1sDDZw38uq7U7NvQNkh/57iiGiAJoYGsy6B gK3s8ABt0zhM= X-Received: by 2002:a19:e00e:0:b0:50a:a33a:942f with SMTP id x14-20020a19e00e000000b0050aa33a942fmr122382lfg.65.1700594691205; Tue, 21 Nov 2023 11:24:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IGbJkJ5NofWbp97r8reFiCeRWG29zI/6Ilkga2O5SfCerpyxE6wQCQzah73J2M1c62N9P0N8A== X-Received: by 2002:a19:e00e:0:b0:50a:a33a:942f with SMTP id x14-20020a19e00e000000b0050aa33a942fmr122359lfg.65.1700594690721; Tue, 21 Nov 2023 11:24:50 -0800 (PST) Received: from ?IPV6:2003:cb:c722:be00:f0e5:e79a:9640:afaa? (p200300cbc722be00f0e5e79a9640afaa.dip0.t-ipconnect.de. [2003:cb:c722:be00:f0e5:e79a:9640:afaa]) by smtp.gmail.com with ESMTPSA id f11-20020a19380b000000b0050a6f5a186bsm1606540lfa.293.2023.11.21.11.24.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Nov 2023 11:24:50 -0800 (PST) Message-ID: Date: Tue, 21 Nov 2023 20:24:48 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 0/8] implement "memmap on memory" feature on s390 To: Sumanth Korikkar Cc: Gerald Schaefer , linux-mm , Andrew Morton , Oscar Salvador , Michal Hocko , "Aneesh Kumar K.V" , Anshuman Khandual , Alexander Gordeev , Heiko Carstens , Vasily Gorbik , linux-s390 , LKML References: <20231114180238.1522782-1-sumanthk@linux.ibm.com> <20231117140009.5d8a509c@thinkpad-T15> From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8NJgW0k/D1RyKCwaTsgRd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ms6t1trDQmPx2iP5+7iDsb7OKAb5eOS8h+BEBDeq 3ecsQDv0fFJOA9ag5O3LLNk+3x3q7e0uo06XMaY7UHS341ozXUUI7wC7iKfoUTv03iO9El5f XpNMx/YrIMduZ2+nd9Di7o5+KIwlb2mAB9sTNHdMrXesX8eBL6T9b+MZJk+mZuPxKNVfEQMQ a5SxUEADIPQTPNvBewdeI80yeOCrN+Zzwy/Mrx9EPeu59Y5vSJOx/z6OUImD/GhX7Xvkt3kq Er5KTrJz3++B6SH9pum9PuoE/k+nntJkNMmQpR4MCBaV/J9gIOPGodDKnjdng+mXliF3Ptu6 3oxc2RCyGzTlxyMwuc2U5Q7KtUNTdDe8T0uE+9b8BLMVQDDfJjqY0VVqSUwImzTDLX9S4g/8 kC4HRcclk8hpyhY2jKGluZO0awwTIMgVEzmTyBphDg/Gx7dZU1Xf8HFuE+UZ5UDHDTnwgv7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 9D94A120019 X-Stat-Signature: q5rj1u5386qka1qpyo4pd6bshxqz8azt X-HE-Tag: 1700594695-986366 X-HE-Meta: U2FsdGVkX180EHeJTquVKPa13ojgz5Jw+J7gFVZB2mZS9k6a4q+CVspsFodWQBcllNhDrC45wASd1VI3beFbvPc3psh1VfCET0XSme/5IFkghrKg9ylTticQR0fwl5B3bweopYenN+zG7+l2BrgUuR4WWAsJhBHXmW5QCjorDx3D02+xzZGuoe9t16wWvxj4QD25icgFBcbeVvvpf1ezJCnUPSX/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H0xwvBv+XRRtP92vaDP7CO5Vy6GFJmU0owl90F8TeJgmWV3jApU6LlRs95gsZGKYey3kK+kr+uIipdBOAfhxvtjs4KpqPJW7qzUMydBBR2uiQLIwmLE/b/bHnxizg/CMK8VBNN10= 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: List-Subscribe: List-Unsubscribe: On 21.11.23 14:13, Sumanth Korikkar wrote: > On Fri, Nov 17, 2023 at 04:37:29PM +0100, David Hildenbrand wrote: >>> >>> Maybe there is also already a common code bug with that, s390 might be >>> special but that is often also good for finding bugs in common code ... >> >> If it's only the page_init_poison() as noted by Sumanth, we could disable >> that on s390x with an altmap some way or the other; should be possible. >> >> I mean, you effectively have your own poisoning if the altmap is effectively >> inaccessible and makes your CPU angry on access :) >> >> Last but not least, support for an inaccessible altmap might come in handy >> for virtio-mem eventually, and make altmap support eventually simpler. So >> added bonus points. > > We tried out two possibilities dealing with vmemmap altmap inaccessibilty. > Approach 1: Add MHP_ALTMAP_INACCESSIBLE flag and pass it in add_memory() > > diff --git a/drivers/s390/char/sclp_cmd.c b/drivers/s390/char/sclp_cmd.c > index 075094ca59b4..ab2dfcc7e9e4 100644 > --- a/drivers/s390/char/sclp_cmd.c > +++ b/drivers/s390/char/sclp_cmd.c > @@ -358,6 +358,13 @@ static int sclp_mem_notifier(struct notifier_block *nb, > * buddy allocator later. > */ > __arch_set_page_nodat((void *)__va(start), memory_block->altmap->free); > + /* > + * Poison the struct pages after memory block is accessible. > + * This is needed for only altmap. Without altmap, the struct > + * pages are poisoined in sparse_add_section(). > + */ > + if (memory_block->altmap->inaccessible) > + page_init_poison(pfn_to_page(arg->start_pfn), memory_block->altmap->free); See below, likely it's best if the core will do that. > break; > case MEM_FINISH_OFFLINE: > sclp_mem_change_state(start, size, 0); > @@ -412,7 +419,7 @@ static void __init add_memory_merged(u16 rn) > goto skip_add; > for (addr = start; addr < start + size; addr += block_size) > add_memory(0, addr, block_size, > - MACHINE_HAS_EDAT1 ? MHP_MEMMAP_ON_MEMORY : MHP_NONE); > + MACHINE_HAS_EDAT1 ? MHP_MEMMAP_ON_MEMORY|MHP_ALTMAP_INACCESSIBLE : MHP_NONE); > skip_add: > first_rn = rn; > num = 1; > diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h > index 7d2076583494..5c70707e706f 100644 > --- a/include/linux/memory_hotplug.h > +++ b/include/linux/memory_hotplug.h > @@ -106,6 +106,11 @@ typedef int __bitwise mhp_t; > * implies the node id (nid). > */ > #define MHP_NID_IS_MGID ((__force mhp_t)BIT(2)) > +/* > + * Mark memmap on memory (struct pages array) as inaccessible during memory > + * hotplug addition phase. > + */ > +#define MHP_ALTMAP_INACCESSIBLE ((__force mhp_t)BIT(3)) If we go that path, maybe rather MHP_OFFLINE_INACCESSIBLE and document how this relates to/interacts with the memory notifier callbacks and the altmap. Then, we can logically abstract this from altmap handling. Simply, the memory should not be read/written before the memory notifier was called. In the core, you can do the poisioning for the altmap in that case after calling the notifier, probably in mhp_init_memmap_on_memory() as you do below. > > /* > * Extended parameters for memory hotplug: > diff --git a/include/linux/memremap.h b/include/linux/memremap.h > index 744c830f4b13..9837f3e6fb95 100644 > --- a/include/linux/memremap.h > +++ b/include/linux/memremap.h > @@ -25,6 +25,7 @@ struct vmem_altmap { > unsigned long free; > unsigned long align; > unsigned long alloc; > + bool inaccessible; We should then likely remember that information for the memory block, not the altmap. [...] > > > Approach 2: > =========== > Shouldnt kasan zero shadow mapping performed first before > accessing/initializing memmap via page_init_poisining()? If that is Likely the existing way. The first access to the poisoned memmap should be a write, not a read. But I didn't look into the details. Can you try reproducing? > true, then it is a problem for all architectures and should could be > fixed like: > > > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index 7a5fc89a8652..eb3975740537 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -1093,6 +1093,7 @@ int mhp_init_memmap_on_memory(unsigned long pfn, unsigned long nr_pages, > if (ret) > return ret; > > + page_init_poison(pfn_to_page(pfn), sizeof(struct page) * nr_pages); > move_pfn_range_to_zone(zone, pfn, nr_pages, NULL, MIGRATE_UNMOVABLE); > > for (i = 0; i < nr_pages; i++) > diff --git a/mm/sparse.c b/mm/sparse.c > index 77d91e565045..4ddf53f52075 100644 > --- a/mm/sparse.c > +++ b/mm/sparse.c > @@ -906,8 +906,11 @@ int __meminit sparse_add_section(int nid, unsigned long start_pfn, > /* > * Poison uninitialized struct pages in order to catch invalid flags > * combinations. > + * For altmap, do this later when onlining the memory, as it might > + * not be accessible at this point. > */ > - page_init_poison(memmap, sizeof(struct page) * nr_pages); > + if (!altmap) > + page_init_poison(memmap, sizeof(struct page) * nr_pages); > > ms = __nr_to_section(section_nr); > set_section_nid(section_nr, nid); > That's too generic when it comes to other altmap users, especially DAX or when the altmap is accessible while memory is offlining, and we want to catch that. > > > Also, if this approach is taken, should page_init_poison() be performed > with cond_resched() as mentioned in commit d33695b16a9f > ("mm/memory_hotplug: poison memmap in remove_pfn_range_from_zone()") ? Likely as soon as possible after it is accessible :) -- Cheers, David / dhildenb