From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2744E2F25E3 for ; Wed, 8 Oct 2025 08:05:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759910745; cv=none; b=JM0A1GDaz/pDrhPQD5qiAWqYRYDJtJS8sIHeU3zVZH9zK0FFT/zIuzDrV+owwZM/VCPB3JucW5XolHqk6UV3WVjuMoQZ0LnQqRm1sPrXz5n7dGPRFF6qsRmHyExagJwOkC8qfRHlv0s5XzPrz4H3aN8KSyPuaMZrhNv950lAWDk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759910745; c=relaxed/simple; bh=yq/iDEiQ1RPX6RmohINmLnUzpZ9jfovo6KITeqhLMRM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=uddoQjXpB/FVY1rPTf2HXJphAAOc9opre+Us9dNDXeyu0Tbs45wgpiUWkGMk2Da16K1CU0ac3PpQKzUj+WHKYFaFpTehD1xuvTayy/mzslfSMW79D8NSQtqTyc1yD/1Wa6Sl1Z+GHPSRJcgX0eb14Peo8DduC6nplCNZm+tgT9Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ErINyHjp; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ErINyHjp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759910743; 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=Fckckqu8FhSLe+YJGblmZ5Veu3gXLrLCsl3rTsripxs=; b=ErINyHjpcPMn/buFcwqkkyl7/ECnVH/DPVQJb6X2mWY3ioFBpzcs7J6wS9FNyZY810vTOG bxu6lGSxvspMEOL+VbdUIDcDycRrZXJCdT6MichQdnDYrwL68b+AqtpWezRJzrJ8fnDaj8 xj9Fq3A83jAaps2N2ODbeZuwnErPpwQ= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-283-Of0rFx3BP7qzpRFzkeNFOQ-1; Wed, 08 Oct 2025 04:05:41 -0400 X-MC-Unique: Of0rFx3BP7qzpRFzkeNFOQ-1 X-Mimecast-MFC-AGG-ID: Of0rFx3BP7qzpRFzkeNFOQ_1759910740 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-46e38bd6680so24153335e9.1 for ; Wed, 08 Oct 2025 01:05:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759910740; x=1760515540; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :from: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=Fckckqu8FhSLe+YJGblmZ5Veu3gXLrLCsl3rTsripxs=; b=IEZaK3ZEWLVV+yJYBIu1lVr3q+E2/nX8gzlYdp5Md+ROI8srX4vJ3WWyGSmrclgP3H Z5xzsOoy0YykC3y5QT2we8NsYMM7DIGqRfuQxrp+JZJ2/dp91SVKwZselFxzsWqnaxWQ 6qkcPYQsUdNfq4ZTpaHxvvdHn81mxqRAau2kMwLcH7lccMbNBcHTTX3/+VHOSK64LWea PyP0ZjiZwENIAVsVoOmJi3VcfhINr2viX/QjrhufxllMyuT4ELIzBMPOoDo1WyreFJ28 J24W5vlkCKrho6urU9k8mHbKTigMYfiaB3Y61PrSJgGYRUjHG9Wmptr7p2FonbERXuD1 JxJA== X-Forwarded-Encrypted: i=1; AJvYcCXbjfEQVWrawZUO0sqzR0SzSA1X1G04y3/ufq41NjeNjiVQJ5uYyv6rA2W8BbVYqWyvFNDOtq6gfqz93nk=@vger.kernel.org X-Gm-Message-State: AOJu0YyJ4hep+PbYVrJZllMm1ykXc+VMJoYwnRqY9OORrhrWMN3LaZNs o6GcyF4+VztOUxwFnySiB1tglc2L8/MtsQ2at3Rh5zyooM6SE3LwO0/tj51xcJgMmcIK+146Qi/ a5z1Y/9f/RwAvgV2df+WOHLn9ZOM9pKGwzuLsnqcfnywvoa1pODc24NTx/zCNt8D4Pg== X-Gm-Gg: ASbGncvOMtk9L0wTU5DvOeHBXtoB/idxcmRZaOpbjx+4Egy0p+1fihs8ngVs8ROTGjv iw+sKLVXB7J1Od/PUCQm0nx8OVjMivqiGzsuoHBe8515X8oMUTfjvUzVKrDJhNLb17G6DUJOFrs dh3oOt+g7m63ornd9RnOrNAo3D5qBZcWh8600gY/fUcg75jVr9kOxB78hqxncuH4+jSDCIT1e54 2MUt/VfD1AEHwfv+WI2DSVk7cwOJgAbhgn1JoWPbsR1Q9O1M73eut0RAqmaXnuqti5BTU6VdxIF XZQIjCwlnL4W+3xfUWBguz1J8u9PzXOtfXrKuU4Q5XewtkRW9ETdcJ7RIRYK5Dsg6jOJ798fJ0d zX1UdFNyM X-Received: by 2002:a05:600c:1395:b0:46e:37fc:def0 with SMTP id 5b1f17b1804b1-46fa9a9efaamr17049965e9.9.1759910740317; Wed, 08 Oct 2025 01:05:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG01JXdA7zG4WT7hRXme96s2VqM9oTOcf5aTlv4lkpg5WkgJHOM8zu4tbyk7O6KwitLxTnxnw== X-Received: by 2002:a05:600c:1395:b0:46e:37fc:def0 with SMTP id 5b1f17b1804b1-46fa9a9efaamr17049655e9.9.1759910739866; Wed, 08 Oct 2025 01:05:39 -0700 (PDT) Received: from [192.168.3.141] (tmo-083-110.customers.d1-online.com. [80.187.83.110]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8ac750sm29018283f8f.24.2025.10.08.01.05.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 Oct 2025 01:05:39 -0700 (PDT) Message-ID: <60066a80-4758-4034-bbd8-25d9c24861b9@redhat.com> Date: Wed, 8 Oct 2025 10:05:37 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/4] s390/sclp: Add support for dynamic (de)configuration of memory To: Sumanth Korikkar Cc: Andrew Morton , linux-mm , LKML , linux-s390 , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Alexander Gordeev References: <20250926131527.3260733-1-sumanthk@linux.ibm.com> <20250926131527.3260733-3-sumanthk@linux.ibm.com> <4e832570-32f8-46a5-80d0-40570db862b2@redhat.com> From: David Hildenbrand Content-Language: en-US Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID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EXwDKQu+P/vts IfUb1UNMfMV76BicGa5NCZnJNQASDP/+bFg6O3gx5NbhHHPeaWz/VxlOmYHokHodOvtL0WCC 8A5PEP8tOk6029Z+J+xUcMrJClNVFpzVvOpb1lCbhjwAV465Hy+NUSbbUiRxdzNQtLtgZzOV Zw7jxUCs4UUZLQTCuBpFgb15bBxYZ/BL9MbzxPxvfUQIPbnzQMcqtpUs21CMK2PdfCh5c4gS sDci6D5/ZIBw94UQWmGpM/O1ilGXde2ZzzGYl64glmccD8e87OnEgKnH3FbnJnT4iJchtSvx yJNi1+t0+qDti4m88+/9IuPqCKb6Stl+s2dnLtJNrjXBGJtsQG/sRpqsJz5x1/2nPJSRMsx9 5YfqbdrJSOFXDzZ8/r82HgQEtUvlSXNaXCa95ez0UkOG7+bDm2b3s0XahBQeLVCH0mw3RAQg r7xDAYKIrAwfHHmMTnBQDPJwVqxJjVNr7yBic4yfzVWGCGNE4DnOW0vcIeoyhy9vnIa3w1uZ 3iyY2Nsd7JxfKu1PRhCGwXzRw5TlfEsoRI7V9A8isUCoqE2Dzh3FvYHVeX4Us+bRL/oqareJ CIFqgYMyvHj7Q06kTKmauOe4Nf0l0qEkIuIzfoLJ3qr5UyXc2hLtWyT9Ir+lYlX9efqh7mOY qIws/H2t In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit >> Is there any reson this notifier is still needed? I'd assume we can just allow >> for offlining + re-onlining as we please now. >> >> In fact, I'd assume we can get rid of the notifier entirely now? > > I was initially uncertain about contains_standby_increment() use case > and didnt change it here. However, after testing by removing the > contains_standby_increment() checks, I observed that the common memory > hotplug code already prevents offlining a memory block that contains > holes. This ensures safety without relying on these checks. > > c5e79ef561b0 ("mm/memory_hotplug.c: don't allow to online/offline memory blocks with holes") Rings a bell :) > > i.e. #cp define storage 3504M standby 2148M > This leads to a configuration where memory block 27 contains both > assigned and standby incr. > > But, offlining it will not succeed: > chmem -d 0x00000000d8000000-0x00000000dfffffff > chmem: Memory Block 27 (0x00000000d8000000-0x00000000dfffffff) disable > failed: Invalid argument > > Hence, I will remove it. Thanks. Cool! > >>> - case MEM_PREPARE_ONLINE: >>> - /* >>> - * Access the altmap_start_pfn and altmap_nr_pages fields >>> - * within the struct memory_notify specifically when dealing >>> - * with only MEM_PREPARE_ONLINE/MEM_FINISH_OFFLINE notifiers. >>> - * >>> - * When altmap is in use, take the specified memory range >>> - * online, which includes the altmap. >>> - */ >>> - if (arg->altmap_nr_pages) { >>> - start = PFN_PHYS(arg->altmap_start_pfn); >>> - size += PFN_PHYS(arg->altmap_nr_pages); >>> - } >>> - rc = sclp_mem_change_state(start, size, 1); >>> - if (rc || !arg->altmap_nr_pages) >>> - break; >>> - /* >>> - * Set CMMA state to nodat here, since the struct page memory >>> - * at the beginning of the memory block will not go through the >>> - * buddy allocator later. >>> - */ >>> - __arch_set_page_nodat((void *)__va(start), arg->altmap_nr_pages); >>> + default: >>> break; >>> - case MEM_FINISH_OFFLINE: >>> + } >>> + return rc ? NOTIFY_BAD : NOTIFY_OK; >>> +} >>> + >>> +static ssize_t config_mblock_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) >>> +{ >>> + struct mblock *mblock = container_of(kobj, struct mblock, kobj); >>> + >>> + return sysfs_emit(buf, "%u\n", READ_ONCE(mblock->config)); >>> +} >>> + >>> +static ssize_t config_mblock_store(struct kobject *kobj, struct kobj_attribute *attr, >>> + const char *buf, size_t count) >>> +{ >>> + unsigned long long addr, block_size; >> >> "unsigned long" should be sufficient I'm sure :) > > Left over. I will do so. > >>> + struct memory_block *mem; >>> + struct mblock *mblock; >>> + unsigned char id; >>> + bool value; >>> + int rc; >>> + >>> + rc = kstrtobool(buf, &value); >>> + if (rc) >>> + return rc; >>> + mblock = container_of(kobj, struct mblock, kobj); >>> + block_size = memory_block_size_bytes(); >>> + addr = mblock->id * block_size; >>> + /* >>> + * Hold device_hotplug_lock when adding/removing memory blocks. >>> + * Additionally, also protect calls to find_memory_block() and >>> + * sclp_attach_storage(). >>> + */ >>> + rc = lock_device_hotplug_sysfs(); >>> + if (rc) >>> + goto out; >>> + for_each_clear_bit(id, sclp_storage_ids, sclp_max_storage_id + 1) >>> + sclp_attach_storage(id); >>> + if (value) { >>> + if (mblock->config) >>> + goto out_unlock; >>> + rc = sclp_mem_change_state(addr, block_size, 1); >>> + if (rc) >>> + goto out_unlock; >>> /* >>> - * When altmap is in use, take the specified memory range >>> - * offline, which includes the altmap. >>> + * Set entire memory block CMMA state to nodat. Later, when >>> + * page tables pages are allocated via __add_memory(), those >>> + * regions are marked __arch_set_page_dat(). >>> */ >>> - if (arg->altmap_nr_pages) { >>> - start = PFN_PHYS(arg->altmap_start_pfn); >>> - size += PFN_PHYS(arg->altmap_nr_pages); >>> + __arch_set_page_nodat((void *)__va(addr), block_size >> PAGE_SHIFT); >>> + rc = __add_memory(0, addr, block_size, >>> + mblock->memmap_on_memory ? >>> + MHP_MEMMAP_ON_MEMORY | MHP_OFFLINE_INACCESSIBLE : MHP_NONE); >>> + if (rc) >>> + goto out_unlock; >> >> Do we have to undo the state change? > > Intention was to keep error handling simple. In case of failure in > add_memory(), we would have state set to 1 (not given back). But, > subsequent configuration request for that block will not have an impact. I mean, if we can cleanup easily here by doing another sclp_mem_change_state(), I think we should just do that. I'd assume that sclp_mem_change_state() to 0 will usually not fail (I might be wrong :) ). [...] >>> -static int __init sclp_detect_standby_memory(void) >>> +static int __init sclp_setup_memory(void) >>> { >>> struct read_storage_sccb *sccb; >>> int i, id, assigned, rc; >>> + struct mblock *mblocks; >>> + struct kset *kset; >>> /* No standby memory in kdump mode */ >>> if (oldmem_data.start) >> >> Wouldn't we still want to create the ones for initial memory at least? > > Intention was the following: > configuration and deconfiguration of memory with optional > memmap-on-memory is mostly needed for only standby memory. > > If standby memory is absent or sclp is unavailable, we continue using > the previous behavior (only software offline/online), since the sclp > memory notifier was not registered in that case before either. I mean, probably nobody in the kdump kernel cares about it either way, agreed. -- Cheers David / dhildenb