From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paul Mackerras Subject: Re: [PATCH] KVM: PPC: Book3S: Ratelimit copy data failure error messages Date: Thu, 16 Feb 2017 16:31:59 +1100 Message-ID: <20170216053159.GD19110@fergus.ozlabs.ibm.com> References: <1487012190-19830-1-git-send-email-vipin@linux.vnet.ibm.com> <293fadf7-0d63-91e3-f9f2-5d641269927a@linux.vnet.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm-ppc@vger.kernel.org, kvm@vger.kernel.org To: Vipin K Parashar Return-path: Received: from ozlabs.org ([103.22.144.67]:47699 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753722AbdBPFcF (ORCPT ); Thu, 16 Feb 2017 00:32:05 -0500 Content-Disposition: inline In-Reply-To: <293fadf7-0d63-91e3-f9f2-5d641269927a@linux.vnet.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Feb 14, 2017 at 11:42:21AM +0530, Vipin K Parashar wrote: > kvm_ppc_mmu_book3s_32/64 xlat() log "KVM can't copy data" error > upon failing to copy user data to kernel space. This floods kernel > log once such fails occur in short time period. Ratelimit this > error to avoid flooding kernel logs upon copy data failures. > > Signed-off-by: Vipin K Parashar > --- > arch/powerpc/kvm/book3s_32_mmu.c | 3 ++- > arch/powerpc/kvm/book3s_64_mmu.c | 3 ++- > 2 files changed, 4 insertions(+), 2 deletions(-) > > diff --git a/arch/powerpc/kvm/book3s_32_mmu.c b/arch/powerpc/kvm/book3s_32_mmu.c > index a2eb6d3..ca8f960 100644 > --- a/arch/powerpc/kvm/book3s_32_mmu.c > +++ b/arch/powerpc/kvm/book3s_32_mmu.c > @@ -224,7 +224,8 @@ static int kvmppc_mmu_book3s_32_xlate_pte(struct kvm_vcpu *vcpu, gva_t eaddr, > ptem = kvmppc_mmu_book3s_32_get_ptem(sre, eaddr, primary); > > if(copy_from_user(pteg, (void __user *)ptegp, sizeof(pteg))) { > - printk(KERN_ERR "KVM: Can't copy data from 0x%lx!\n", ptegp); > + if (printk_ratelimit()) > + printk(KERN_ERR "KVM: Can't copy data from 0x%lx!\n", ptegp); I found this in include/linux/printk.h: /* * Please don't use printk_ratelimit(), because it shares ratelimiting state * with all other unrelated printk_ratelimit() callsites. Instead use * printk_ratelimited() or plain old __ratelimit(). */ It does seem that using printk_ratelimited(KERN_ERR ...) or the equivalent pr_err_ratelimited(...) would be a better option. Paul. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paul Mackerras Date: Thu, 16 Feb 2017 05:31:59 +0000 Subject: Re: [PATCH] KVM: PPC: Book3S: Ratelimit copy data failure error messages Message-Id: <20170216053159.GD19110@fergus.ozlabs.ibm.com> List-Id: References: <1487012190-19830-1-git-send-email-vipin@linux.vnet.ibm.com> <293fadf7-0d63-91e3-f9f2-5d641269927a@linux.vnet.ibm.com> In-Reply-To: <293fadf7-0d63-91e3-f9f2-5d641269927a@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Vipin K Parashar Cc: kvm-ppc@vger.kernel.org, kvm@vger.kernel.org On Tue, Feb 14, 2017 at 11:42:21AM +0530, Vipin K Parashar wrote: > kvm_ppc_mmu_book3s_32/64 xlat() log "KVM can't copy data" error > upon failing to copy user data to kernel space. This floods kernel > log once such fails occur in short time period. Ratelimit this > error to avoid flooding kernel logs upon copy data failures. > > Signed-off-by: Vipin K Parashar > --- > arch/powerpc/kvm/book3s_32_mmu.c | 3 ++- > arch/powerpc/kvm/book3s_64_mmu.c | 3 ++- > 2 files changed, 4 insertions(+), 2 deletions(-) > > diff --git a/arch/powerpc/kvm/book3s_32_mmu.c b/arch/powerpc/kvm/book3s_32_mmu.c > index a2eb6d3..ca8f960 100644 > --- a/arch/powerpc/kvm/book3s_32_mmu.c > +++ b/arch/powerpc/kvm/book3s_32_mmu.c > @@ -224,7 +224,8 @@ static int kvmppc_mmu_book3s_32_xlate_pte(struct kvm_vcpu *vcpu, gva_t eaddr, > ptem = kvmppc_mmu_book3s_32_get_ptem(sre, eaddr, primary); > > if(copy_from_user(pteg, (void __user *)ptegp, sizeof(pteg))) { > - printk(KERN_ERR "KVM: Can't copy data from 0x%lx!\n", ptegp); > + if (printk_ratelimit()) > + printk(KERN_ERR "KVM: Can't copy data from 0x%lx!\n", ptegp); I found this in include/linux/printk.h: /* * Please don't use printk_ratelimit(), because it shares ratelimiting state * with all other unrelated printk_ratelimit() callsites. Instead use * printk_ratelimited() or plain old __ratelimit(). */ It does seem that using printk_ratelimited(KERN_ERR ...) or the equivalent pr_err_ratelimited(...) would be a better option. Paul.