From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34950) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cegpk-0005B8-R0 for qemu-devel@nongnu.org; Fri, 17 Feb 2017 06:36:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cegpj-00041N-Uu for qemu-devel@nongnu.org; Fri, 17 Feb 2017 06:36:16 -0500 Date: Fri, 17 Feb 2017 11:36:03 +0000 From: "Dr. David Alan Gilbert" Message-ID: <20170217113601.GB4941@work-vm> References: <1487318764-29513-1-git-send-email-pagupta@redhat.com> <1323841238.24175066.1487331028566.JavaMail.zimbra@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1323841238.24175066.1487331028566.JavaMail.zimbra@redhat.com> Subject: Re: [Qemu-devel] [Qemu-block] [PATCH] block, migration: Use qemu_madvise inplace of madvise List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pankaj Gupta Cc: Alberto Garcia , qemu-block@nongnu.org, qemu-devel@nongnu.org, kwolf@redhat.com, quintela@redhat.com, mreitz@redhat.com * Pankaj Gupta (pagupta@redhat.com) wrote: > > Thanks for your comments. I have below query. > > > > On Fri 17 Feb 2017 09:06:04 AM CET, Pankaj Gupta wrote: > > > To maintain consistency at all the places use qemu_madvise wrapper > > > inplace of madvise call. > > > > > if (length > 0) { > > > - madvise((uint8_t *) t + offset, length, MADV_DONTNEED); > > > + qemu_madvise((uint8_t *) t + offset, length, QEMU_MADV_DONTNEED); > > > > This was changed two months ago from qemu_madvise() to madvise(), is > > there any reason why you want to revert that change? Those two calls are > > not equivalent, please see commit 2f2c8d6b371cfc6689affb0b7e for an > > explanation. > > > > > - if (madvise(start, length, MADV_DONTNEED)) { > > > + if (qemu_madvise(start, length, QEMU_MADV_DONTNEED)) { > > > error_report("%s MADV_DONTNEED: %s", __func__, strerror(errno)); > > I checked history of only change related to 'postcopy'. > > For my linux machine: > > ./config-host.mak > > CONFIG_MADVISE=y > CONFIG_POSIX_MADVISE=y > > As both these options are set for Linux, every time we call call 'qemu_madvise' ==>"madvise(addr, len, advice);" will > be compiled/called. I don't understand why '2f2c8d6b371cfc6689affb0b7e' explicitly changed for :"#ifdef CONFIG_LINUX" > I think its better to write generic function maybe in a wrapper then to conditionally set something at different places. No; the problem is that the behaviours are different. You're right that the current build on Linux defines MADVISE and thus we are safe because qemu_madvise takes teh CONFIG_MADVISE/madvise route - but we need to be explicit that it's only the madvise() route that's safe, not any of the calls implemented by qemu_madvise, because if in the future someone was to rearrange qemu_madvise to prefer posix_madvise postcopy would break in a very subtle way. IMHO it might even be better to remove the definition of QEMU_MADV_DONTNEED altogether and make a name that wasn't ambiguous between the two, since the posix definition is so different. Dave > int qemu_madvise(void *addr, size_t len, int advice) > { > if (advice == QEMU_MADV_INVALID) { > errno = EINVAL; > return -1; > } > #if defined(CONFIG_MADVISE) > return madvise(addr, len, advice); > #elif defined(CONFIG_POSIX_MADVISE) > return posix_madvise(addr, len, advice); > #else > errno = EINVAL; > return -1; > #endif > } > > > > > And this is the same case. > > > > Berto > > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK