linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [Question] mm/resource: a mistake to use IORESOURCE_SYSRAM instead of IORESOURCE_SYSTEM_RAM?
@ 2021-12-21 10:14 Eric Ren
       [not found] ` <92d3d4c3-5756-5df5-36e1-ad2e99aef21f@redhat.com>
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Ren @ 2021-12-21 10:14 UTC (permalink / raw)
  To: linux-mm, David Hildenbrand

Hi David,

I feel confused on this piece of code:

```
void release_mem_region_adjustable(resource_size_t start, 
resource_size_t size)
{
... snip
/*
          * All memory regions added from memory-hotplug path have the
          * flag IORESOURCE_SYSTEM_RAM. If the resource does not have
          * this flag, we know that we are dealing with a resource coming
          * from HMM/devm. HMM/devm use another mechanism to add/release
          * a resource. This goes via devm_request_mem_region and
          * devm_release_mem_region.
          * HMM/devm take care to release their resources when they want,
          * so if we are dealing with them, let us just back off here.
          */
         if (!(res->flags & IORESOURCE_SYSRAM)) {
             break;
         }
```

The comment says IORESOURCE_SYSTEM_RAM while IORESOURCE_SYSRAM is 
actually used.
Is this a mistake?

The reason why I come to read about this is that, I got -EEXIST error from
add_memory_driver_managed() when I want to virtio_mem regions sitting on 
Reserved
memory region like this in /proc/iomem:
```
fffc0000-183fffffff : Reserved
   100000000-183fffffff : System RAM (virtio_mem)
     1820000000-183fffffff : System RAM (virtio_mem) // --> plugged MB
```

EEXIST error happens after plug -> unplug -> plug testing, because the
hot-added region remains after unplug. The hot-added region is under
Reserved region. The IORESOURCE_SYSRAM flag check will skips to handle
children of the Reserved region.
Thanks in advance!
Eric



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Question] mm/resource: a mistake to use IORESOURCE_SYSRAM instead of IORESOURCE_SYSTEM_RAM?
       [not found] ` <92d3d4c3-5756-5df5-36e1-ad2e99aef21f@redhat.com>
@ 2021-12-21 14:14   ` Eric Ren
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Ren @ 2021-12-21 14:14 UTC (permalink / raw)
  To: David Hildenbrand, linux-mm

Hi,

在 12/21/21 6:40 PM, David Hildenbrand 写道:
> On 21.12.21 11:14, Eric Ren wrote:
>> Hi David,
> Hi Eric,
>
>> I feel confused on this piece of code:
>>
>> ```
>> void release_mem_region_adjustable(resource_size_t start,
>> resource_size_t size)
>> {
>> ... snip
>> /*
>>            * All memory regions added from memory-hotplug path have the
>>            * flag IORESOURCE_SYSTEM_RAM. If the resource does not have
>>            * this flag, we know that we are dealing with a resource coming
>>            * from HMM/devm. HMM/devm use another mechanism to add/release
>>            * a resource. This goes via devm_request_mem_region and
>>            * devm_release_mem_region.
>>            * HMM/devm take care to release their resources when they want,
>>            * so if we are dealing with them, let us just back off here.
>>            */
>>           if (!(res->flags & IORESOURCE_SYSRAM)) {
>>               break;
>>           }
>> ```
>>
>> The comment says IORESOURCE_SYSTEM_RAM while IORESOURCE_SYSRAM is
>> actually used.
>> Is this a mistake?
> IORESOURCE_SYSTEM_RAM is really just (IORESOURCE_MEM|IORESOURCE_SYSRAM)
>
> So it's sufficient to check for IORESOURCE_SYSRAM ("release_mem_region"
> implies that it's a mem region)
Thanks. My doubt is cleared.
>
>> The reason why I come to read about this is that, I got -EEXIST error from
>> add_memory_driver_managed() when I want to virtio_mem regions sitting on
>> Reserved
>> memory region like this in /proc/iomem:
>> ```
>> fffc0000-183fffffff : Reserved
>>     100000000-183fffffff : System RAM (virtio_mem)
>>       1820000000-183fffffff : System RAM (virtio_mem) // --> plugged MB
>> ```
> That looks broken.
>
> Where did the __request_mem_region(IORESOURCE_SYSTEM_RAM |
> IORESOURCE_EXCLUSIVE) go?
>
> How does the memory end up being marked reserved?
>
> If it's exposed via a firmware-provided memory map, that's a spec
> violation ...
Please see below.
>
>> EEXIST error happens after plug -> unplug -> plug testing, because the
>> hot-added region remains after unplug. The hot-added region is under
>> Reserved region. The IORESOURCE_SYSRAM flag check will skips to handle
>> children of the Reserved region.
>> Thanks in advance!
> Can you elaborate more on the  setup / use case?
Yes, with my special setup, the result above is expected, because 
"Reserved"  resource does
not have IORESOURCE_SYSRAM flag.

I'm doing a hack experirement, that makes virtio_mem use physical memory 
from reserved memory
by using memmap=xxx kernel parameter, instead of using device memory 
backended my hypervisor.

Thanks for your help, and sorry for the noise ;-)

Eric
>
>
>



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-21 14:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-21 10:14 [Question] mm/resource: a mistake to use IORESOURCE_SYSRAM instead of IORESOURCE_SYSTEM_RAM? Eric Ren
     [not found] ` <92d3d4c3-5756-5df5-36e1-ad2e99aef21f@redhat.com>
2021-12-21 14:14   ` Eric Ren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox