From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: virtio-dev-return-2445-cohuck=redhat.com@lists.oasis-open.org Sender: List-Post: List-Help: List-Unsubscribe: List-Subscribe: Received: from lists.oasis-open.org (oasis-open.org [66.179.20.138]) by lists.oasis-open.org (Postfix) with ESMTP id A2B5C5818C9B for ; Thu, 3 Aug 2017 06:18:43 -0700 (PDT) Message-ID: <59832353.1020600@intel.com> Date: Thu, 03 Aug 2017 21:21:23 +0800 From: Wei Wang MIME-Version: 1.0 References: <1501742299-4369-1-git-send-email-wei.w.wang@intel.com> <1501742299-4369-6-git-send-email-wei.w.wang@intel.com> <147332060.38438527.1501748021126.JavaMail.zimbra@redhat.com> <598316DB.4050308@intel.com> <900253471.38532197.1501765506419.JavaMail.zimbra@redhat.com> In-Reply-To: <900253471.38532197.1501765506419.JavaMail.zimbra@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: [virtio-dev] Re: [PATCH v13 5/5] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_VQ To: Pankaj Gupta Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, linux-mm@kvack.org, mst@redhat.com, mhocko@kernel.org, mawilcox@microsoft.com, akpm@linux-foundation.org, virtio-dev@lists.oasis-open.org, david@redhat.com, cornelia huck , mgorman@techsingularity.net, aarcange@redhat.com, amit shah , pbonzini@redhat.com, liliang opensource , yang zhang wz , quan xu List-ID: On 08/03/2017 09:05 PM, Pankaj Gupta wrote: >> On 08/03/2017 04:13 PM, Pankaj Gupta wrote: >>>> + /* Allocate space for find_vqs parameters */ >>>> + vqs = kcalloc(nvqs, sizeof(*vqs), GFP_KERNEL); >>>> + if (!vqs) >>>> + goto err_vq; >>>> + callbacks = kmalloc_array(nvqs, sizeof(*callbacks), GFP_KERNEL); >>>> + if (!callbacks) >>>> + goto err_callback; >>>> + names = kmalloc_array(nvqs, sizeof(*names), GFP_KERNEL); >>> >>> is size here (integer) intentional? >> >> Sorry, I didn't get it. Could you please elaborate more? > This is okay > >> >>>> + if (!names) >>>> + goto err_names; >>>> + >>>> + callbacks[0] = balloon_ack; >>>> + names[0] = "inflate"; >>>> + callbacks[1] = balloon_ack; >>>> + names[1] = "deflate"; >>>> + >>>> + i = 2; >>>> + if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ)) { >>>> + callbacks[i] = stats_request; >>> just thinking if memory for callbacks[3] & names[3] is allocated? >> >> Yes, the above kmalloc_array allocated them. > I mean we have created callbacks array for two entries 0,1? > > callbacks = kmalloc_array(nvqs, sizeof(*callbacks), GFP_KERNEL); > > But we are trying to access location '2' which is third: > > i = 2; > + if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ)) { > + callbacks[i] = stats_request; <---- callbacks[2] > + names[i] = "stats"; <----- names[2] > + i++; > + } > > I am missing anything obvious here? Yes. if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ) is true nvqs will be 3, that is, callbacks[2] is allocated. Best, Wei --------------------------------------------------------------------- To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Wang Subject: Re: [PATCH v13 5/5] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_VQ Date: Thu, 03 Aug 2017 21:21:23 +0800 Message-ID: <59832353.1020600@intel.com> References: <1501742299-4369-1-git-send-email-wei.w.wang@intel.com> <1501742299-4369-6-git-send-email-wei.w.wang@intel.com> <147332060.38438527.1501748021126.JavaMail.zimbra@redhat.com> <598316DB.4050308@intel.com> <900253471.38532197.1501765506419.JavaMail.zimbra@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, linux-mm@kvack.org, mst@redhat.com, mhocko@kernel.org, mawilcox@microsoft.com, akpm@linux-foundation.org, virtio-dev@lists.oasis-open.org, david@redhat.com, cornelia huck , mgorman@techsingularity.net, aarcange@redhat.com, amit shah , pbonzini@redhat.com, liliang opensource , yang zhang wz , quan xu To: Pankaj Gupta Return-path: In-Reply-To: <900253471.38532197.1501765506419.JavaMail.zimbra@redhat.com> Sender: owner-linux-mm@kvack.org List-Id: kvm.vger.kernel.org On 08/03/2017 09:05 PM, Pankaj Gupta wrote: >> On 08/03/2017 04:13 PM, Pankaj Gupta wrote: >>>> + /* Allocate space for find_vqs parameters */ >>>> + vqs = kcalloc(nvqs, sizeof(*vqs), GFP_KERNEL); >>>> + if (!vqs) >>>> + goto err_vq; >>>> + callbacks = kmalloc_array(nvqs, sizeof(*callbacks), GFP_KERNEL); >>>> + if (!callbacks) >>>> + goto err_callback; >>>> + names = kmalloc_array(nvqs, sizeof(*names), GFP_KERNEL); >>> >>> is size here (integer) intentional? >> >> Sorry, I didn't get it. Could you please elaborate more? > This is okay > >> >>>> + if (!names) >>>> + goto err_names; >>>> + >>>> + callbacks[0] = balloon_ack; >>>> + names[0] = "inflate"; >>>> + callbacks[1] = balloon_ack; >>>> + names[1] = "deflate"; >>>> + >>>> + i = 2; >>>> + if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ)) { >>>> + callbacks[i] = stats_request; >>> just thinking if memory for callbacks[3] & names[3] is allocated? >> >> Yes, the above kmalloc_array allocated them. > I mean we have created callbacks array for two entries 0,1? > > callbacks = kmalloc_array(nvqs, sizeof(*callbacks), GFP_KERNEL); > > But we are trying to access location '2' which is third: > > i = 2; > + if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ)) { > + callbacks[i] = stats_request; <---- callbacks[2] > + names[i] = "stats"; <----- names[2] > + i++; > + } > > I am missing anything obvious here? Yes. if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ) is true nvqs will be 3, that is, callbacks[2] is allocated. Best, Wei -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751988AbdHCNSo (ORCPT ); Thu, 3 Aug 2017 09:18:44 -0400 Received: from mga01.intel.com ([192.55.52.88]:46529 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751083AbdHCNSl (ORCPT ); Thu, 3 Aug 2017 09:18:41 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,316,1498546800"; d="scan'208";a="885990465" Message-ID: <59832353.1020600@intel.com> Date: Thu, 03 Aug 2017 21:21:23 +0800 From: Wei Wang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Pankaj Gupta CC: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, linux-mm@kvack.org, mst@redhat.com, mhocko@kernel.org, mawilcox@microsoft.com, akpm@linux-foundation.org, virtio-dev@lists.oasis-open.org, david@redhat.com, cornelia huck , mgorman@techsingularity.net, aarcange@redhat.com, amit shah , pbonzini@redhat.com, liliang opensource , yang zhang wz , quan xu Subject: Re: [PATCH v13 5/5] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_VQ References: <1501742299-4369-1-git-send-email-wei.w.wang@intel.com> <1501742299-4369-6-git-send-email-wei.w.wang@intel.com> <147332060.38438527.1501748021126.JavaMail.zimbra@redhat.com> <598316DB.4050308@intel.com> <900253471.38532197.1501765506419.JavaMail.zimbra@redhat.com> In-Reply-To: <900253471.38532197.1501765506419.JavaMail.zimbra@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/03/2017 09:05 PM, Pankaj Gupta wrote: >> On 08/03/2017 04:13 PM, Pankaj Gupta wrote: >>>> + /* Allocate space for find_vqs parameters */ >>>> + vqs = kcalloc(nvqs, sizeof(*vqs), GFP_KERNEL); >>>> + if (!vqs) >>>> + goto err_vq; >>>> + callbacks = kmalloc_array(nvqs, sizeof(*callbacks), GFP_KERNEL); >>>> + if (!callbacks) >>>> + goto err_callback; >>>> + names = kmalloc_array(nvqs, sizeof(*names), GFP_KERNEL); >>> >>> is size here (integer) intentional? >> >> Sorry, I didn't get it. Could you please elaborate more? > This is okay > >> >>>> + if (!names) >>>> + goto err_names; >>>> + >>>> + callbacks[0] = balloon_ack; >>>> + names[0] = "inflate"; >>>> + callbacks[1] = balloon_ack; >>>> + names[1] = "deflate"; >>>> + >>>> + i = 2; >>>> + if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ)) { >>>> + callbacks[i] = stats_request; >>> just thinking if memory for callbacks[3] & names[3] is allocated? >> >> Yes, the above kmalloc_array allocated them. > I mean we have created callbacks array for two entries 0,1? > > callbacks = kmalloc_array(nvqs, sizeof(*callbacks), GFP_KERNEL); > > But we are trying to access location '2' which is third: > > i = 2; > + if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ)) { > + callbacks[i] = stats_request; <---- callbacks[2] > + names[i] = "stats"; <----- names[2] > + i++; > + } > > I am missing anything obvious here? Yes. if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ) is true nvqs will be 3, that is, callbacks[2] is allocated. Best, Wei