linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] PC, KVM, CMA: Fix regression caused by wrong get_order() use
@ 2014-08-14  5:03 Alexey Kardashevskiy
  2014-08-14  5:13 ` Aneesh Kumar K.V
  2014-08-20  2:44 ` Joonsoo Kim
  0 siblings, 2 replies; 5+ messages in thread
From: Alexey Kardashevskiy @ 2014-08-14  5:03 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: kvm, Alexey Kardashevskiy, Alexander Graf, kvm-ppc, linux-kernel,
	Gleb Natapov, Paul Mackerras, Aneesh Kumar K.V, Paolo Bonzini,
	Joonsoo Kim

fc95ca7284bc54953165cba76c3228bd2cdb9591 claims that there is no
functional change but this is not true as it calls get_order() (which
takes bytes) where it should have called ilog2() and the kernel stops
on VM_BUG_ON().

This replaces get_order() with order_base_2() (round-up version of ilog2).

Suggested-by: Paul Mackerras <paulus@samba.org>
Cc: Alexander Graf <agraf@suse.de>
Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---

Changes:
v2:
* s/ilog2/order_base_2/
* removed cc: <stable@vger.kernel.org> as I got wrong impression that v3.16 is
broken

---
 arch/powerpc/kvm/book3s_hv_builtin.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kvm/book3s_hv_builtin.c b/arch/powerpc/kvm/book3s_hv_builtin.c
index 329d7fd..b9615ba 100644
--- a/arch/powerpc/kvm/book3s_hv_builtin.c
+++ b/arch/powerpc/kvm/book3s_hv_builtin.c
@@ -101,7 +101,7 @@ struct kvm_rma_info *kvm_alloc_rma()
 	ri = kmalloc(sizeof(struct kvm_rma_info), GFP_KERNEL);
 	if (!ri)
 		return NULL;
-	page = cma_alloc(kvm_cma, kvm_rma_pages, get_order(kvm_rma_pages));
+	page = cma_alloc(kvm_cma, kvm_rma_pages, order_base_2(kvm_rma_pages));
 	if (!page)
 		goto err_out;
 	atomic_set(&ri->use_count, 1);
@@ -135,12 +135,12 @@ struct page *kvm_alloc_hpt(unsigned long nr_pages)
 {
 	unsigned long align_pages = HPT_ALIGN_PAGES;
 
-	VM_BUG_ON(get_order(nr_pages) < KVM_CMA_CHUNK_ORDER - PAGE_SHIFT);
+	VM_BUG_ON(order_base_2(nr_pages) < KVM_CMA_CHUNK_ORDER - PAGE_SHIFT);
 
 	/* Old CPUs require HPT aligned on a multiple of its size */
 	if (!cpu_has_feature(CPU_FTR_ARCH_206))
 		align_pages = nr_pages;
-	return cma_alloc(kvm_cma, nr_pages, get_order(align_pages));
+	return cma_alloc(kvm_cma, nr_pages, order_base_2(align_pages));
 }
 EXPORT_SYMBOL_GPL(kvm_alloc_hpt);
 
-- 
2.0.0

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

* Re: [PATCH v2] PC, KVM, CMA: Fix regression caused by wrong get_order() use
  2014-08-14  5:03 [PATCH v2] PC, KVM, CMA: Fix regression caused by wrong get_order() use Alexey Kardashevskiy
@ 2014-08-14  5:13 ` Aneesh Kumar K.V
  2014-08-14 13:40   ` Alexander Graf
  2014-08-20  2:44 ` Joonsoo Kim
  1 sibling, 1 reply; 5+ messages in thread
From: Aneesh Kumar K.V @ 2014-08-14  5:13 UTC (permalink / raw)
  To: Alexey Kardashevskiy, linuxppc-dev
  Cc: kvm, Alexey Kardashevskiy, Alexander Graf, kvm-ppc, linux-kernel,
	Gleb Natapov, Paul Mackerras, Paolo Bonzini, Joonsoo Kim

Alexey Kardashevskiy <aik@ozlabs.ru> writes:

> fc95ca7284bc54953165cba76c3228bd2cdb9591 claims that there is no
> functional change but this is not true as it calls get_order() (which
> takes bytes) where it should have called ilog2() and the kernel stops
> on VM_BUG_ON().
>
> This replaces get_order() with order_base_2() (round-up version of ilog2).
>
> Suggested-by: Paul Mackerras <paulus@samba.org>
> Cc: Alexander Graf <agraf@suse.de>
> Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>

Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

> ---
>
> Changes:
> v2:
> * s/ilog2/order_base_2/
> * removed cc: <stable@vger.kernel.org> as I got wrong impression that v3.16 is
> broken
>
> ---
>  arch/powerpc/kvm/book3s_hv_builtin.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/powerpc/kvm/book3s_hv_builtin.c b/arch/powerpc/kvm/book3s_hv_builtin.c
> index 329d7fd..b9615ba 100644
> --- a/arch/powerpc/kvm/book3s_hv_builtin.c
> +++ b/arch/powerpc/kvm/book3s_hv_builtin.c
> @@ -101,7 +101,7 @@ struct kvm_rma_info *kvm_alloc_rma()
>  	ri = kmalloc(sizeof(struct kvm_rma_info), GFP_KERNEL);
>  	if (!ri)
>  		return NULL;
> -	page = cma_alloc(kvm_cma, kvm_rma_pages, get_order(kvm_rma_pages));
> +	page = cma_alloc(kvm_cma, kvm_rma_pages, order_base_2(kvm_rma_pages));
>  	if (!page)
>  		goto err_out;
>  	atomic_set(&ri->use_count, 1);
> @@ -135,12 +135,12 @@ struct page *kvm_alloc_hpt(unsigned long nr_pages)
>  {
>  	unsigned long align_pages = HPT_ALIGN_PAGES;
>
> -	VM_BUG_ON(get_order(nr_pages) < KVM_CMA_CHUNK_ORDER - PAGE_SHIFT);
> +	VM_BUG_ON(order_base_2(nr_pages) < KVM_CMA_CHUNK_ORDER - PAGE_SHIFT);
>
>  	/* Old CPUs require HPT aligned on a multiple of its size */
>  	if (!cpu_has_feature(CPU_FTR_ARCH_206))
>  		align_pages = nr_pages;
> -	return cma_alloc(kvm_cma, nr_pages, get_order(align_pages));
> +	return cma_alloc(kvm_cma, nr_pages, order_base_2(align_pages));
>  }
>  EXPORT_SYMBOL_GPL(kvm_alloc_hpt);
>
> -- 
> 2.0.0

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

* Re: [PATCH v2] PC, KVM, CMA: Fix regression caused by wrong get_order() use
  2014-08-14  5:13 ` Aneesh Kumar K.V
@ 2014-08-14 13:40   ` Alexander Graf
  2014-08-15  3:00     ` Alexey Kardashevskiy
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander Graf @ 2014-08-14 13:40 UTC (permalink / raw)
  To: Aneesh Kumar K.V, Alexey Kardashevskiy, linuxppc-dev
  Cc: kvm, Gleb Natapov, linux-kernel, kvm-ppc, Paul Mackerras,
	Paolo Bonzini, Joonsoo Kim


On 14.08.14 07:13, Aneesh Kumar K.V wrote:
> Alexey Kardashevskiy <aik@ozlabs.ru> writes:
>
>> fc95ca7284bc54953165cba76c3228bd2cdb9591 claims that there is no
>> functional change but this is not true as it calls get_order() (which
>> takes bytes) where it should have called ilog2() and the kernel stops
>> on VM_BUG_ON().
>>
>> This replaces get_order() with order_base_2() (round-up version of ilog2).
>>
>> Suggested-by: Paul Mackerras <paulus@samba.org>
>> Cc: Alexander Graf <agraf@suse.de>
>> Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
>> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
>> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

So this affects 3.17?


Alex

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

* Re: [PATCH v2] PC, KVM, CMA: Fix regression caused by wrong get_order() use
  2014-08-14 13:40   ` Alexander Graf
@ 2014-08-15  3:00     ` Alexey Kardashevskiy
  0 siblings, 0 replies; 5+ messages in thread
From: Alexey Kardashevskiy @ 2014-08-15  3:00 UTC (permalink / raw)
  To: Alexander Graf, Aneesh Kumar K.V, linuxppc-dev
  Cc: kvm, Gleb Natapov, linux-kernel, kvm-ppc, Paul Mackerras,
	Paolo Bonzini, Joonsoo Kim

On 08/14/2014 11:40 PM, Alexander Graf wrote:
> 
> On 14.08.14 07:13, Aneesh Kumar K.V wrote:
>> Alexey Kardashevskiy <aik@ozlabs.ru> writes:
>>
>>> fc95ca7284bc54953165cba76c3228bd2cdb9591 claims that there is no
>>> functional change but this is not true as it calls get_order() (which
>>> takes bytes) where it should have called ilog2() and the kernel stops
>>> on VM_BUG_ON().
>>>
>>> This replaces get_order() with order_base_2() (round-up version of ilog2).
>>>
>>> Suggested-by: Paul Mackerras <paulus@samba.org>
>>> Cc: Alexander Graf <agraf@suse.de>
>>> Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
>>> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
>>> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>> Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> 
> So this affects 3.17?

Yes.


-- 
Alexey

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

* Re: [PATCH v2] PC, KVM, CMA: Fix regression caused by wrong get_order() use
  2014-08-14  5:03 [PATCH v2] PC, KVM, CMA: Fix regression caused by wrong get_order() use Alexey Kardashevskiy
  2014-08-14  5:13 ` Aneesh Kumar K.V
@ 2014-08-20  2:44 ` Joonsoo Kim
  1 sibling, 0 replies; 5+ messages in thread
From: Joonsoo Kim @ 2014-08-20  2:44 UTC (permalink / raw)
  To: Alexey Kardashevskiy
  Cc: kvm, Gleb Natapov, Alexander Graf, kvm-ppc, linux-kernel,
	Paul Mackerras, Aneesh Kumar K.V, Paolo Bonzini, linuxppc-dev

On Thu, Aug 14, 2014 at 03:03:07PM +1000, Alexey Kardashevskiy wrote:
> fc95ca7284bc54953165cba76c3228bd2cdb9591 claims that there is no
> functional change but this is not true as it calls get_order() (which
> takes bytes) where it should have called ilog2() and the kernel stops
> on VM_BUG_ON().
> 
> This replaces get_order() with order_base_2() (round-up version of ilog2).
> 
> Suggested-by: Paul Mackerras <paulus@samba.org>
> Cc: Alexander Graf <agraf@suse.de>
> Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>

Sorry for my fault. :(

Acked-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>

Thanks.

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

end of thread, other threads:[~2014-08-20  2:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-14  5:03 [PATCH v2] PC, KVM, CMA: Fix regression caused by wrong get_order() use Alexey Kardashevskiy
2014-08-14  5:13 ` Aneesh Kumar K.V
2014-08-14 13:40   ` Alexander Graf
2014-08-15  3:00     ` Alexey Kardashevskiy
2014-08-20  2:44 ` Joonsoo Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).