lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200310115955.GI8447@dhcp22.suse.cz>
Date:   Tue, 10 Mar 2020 12:59:55 +0100
From:   Michal Hocko <mhocko@...nel.org>
To:     David Hildenbrand <david@...hat.com>
Cc:     linux-kernel@...r.kernel.org, linux-mm@...ck.org,
        virtio-dev@...ts.oasis-open.org,
        virtualization@...ts.linux-foundation.org, kvm@...r.kernel.org,
        Andrew Morton <akpm@...ux-foundation.org>,
        "Michael S . Tsirkin" <mst@...hat.com>,
        Jason Wang <jasowang@...hat.com>,
        Oscar Salvador <osalvador@...e.de>,
        Igor Mammedov <imammedo@...hat.com>,
        Dave Young <dyoung@...hat.com>,
        Dan Williams <dan.j.williams@...el.com>,
        Pavel Tatashin <pasha.tatashin@...een.com>,
        Stefan Hajnoczi <stefanha@...hat.com>,
        Vlastimil Babka <vbabka@...e.cz>
Subject: Re: [PATCH v1 07/11] virtio-mem: Allow to offline partially
 unplugged memory blocks

On Tue 10-03-20 12:46:05, David Hildenbrand wrote:
> On 10.03.20 12:43, Michal Hocko wrote:
> > On Mon 02-03-20 14:49:37, David Hildenbrand wrote:
> > [...]
> >> +static void virtio_mem_notify_going_offline(struct virtio_mem *vm,
> >> +					    unsigned long mb_id)
> >> +{
> >> +	const unsigned long nr_pages = PFN_DOWN(vm->subblock_size);
> >> +	unsigned long pfn;
> >> +	int sb_id, i;
> >> +
> >> +	for (sb_id = 0; sb_id < vm->nb_sb_per_mb; sb_id++) {
> >> +		if (virtio_mem_mb_test_sb_plugged(vm, mb_id, sb_id, 1))
> >> +			continue;
> >> +		/*
> >> +		 * Drop our reference to the pages so the memory can get
> >> +		 * offlined and add the unplugged pages to the managed
> >> +		 * page counters (so offlining code can correctly subtract
> >> +		 * them again).
> >> +		 */
> >> +		pfn = PFN_DOWN(virtio_mem_mb_id_to_phys(mb_id) +
> >> +			       sb_id * vm->subblock_size);
> >> +		adjust_managed_page_count(pfn_to_page(pfn), nr_pages);
> >> +		for (i = 0; i < nr_pages; i++)
> >> +			page_ref_dec(pfn_to_page(pfn + i));
> > 
> > Is there ever situation this might be a different than 1->0 transition?
> 
> Only if some other code would be taking a reference. At least not from
> virtio-mem perspective.

OK, so that is essentially an error condition. I think it shouldn't go
silent and you want something like
	if (WARN_ON(!page_ref_sub_and_test(page)))
		dump_page(pfn_to_page(pfn + i), "YOUR REASON");

-- 
Michal Hocko
SUSE Labs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ