From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37785) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwRoa-0004XH-SG for qemu-devel@nongnu.org; Tue, 18 Oct 2016 06:40:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bwRoW-0007z0-Tw for qemu-devel@nongnu.org; Tue, 18 Oct 2016 06:40:12 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:52876 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bwRoW-0007yW-OC for qemu-devel@nongnu.org; Tue, 18 Oct 2016 06:40:08 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u9IAcpr0062885 for ; Tue, 18 Oct 2016 06:40:07 -0400 Received: from e06smtp09.uk.ibm.com (e06smtp09.uk.ibm.com [195.75.94.105]) by mx0b-001b2d01.pphosted.com with ESMTP id 265dnym7qu-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 18 Oct 2016 06:40:07 -0400 Received: from localhost by e06smtp09.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 18 Oct 2016 11:40:06 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id E38851B08070 for ; Tue, 18 Oct 2016 11:42:07 +0100 (BST) Received: from d06av08.portsmouth.uk.ibm.com (d06av08.portsmouth.uk.ibm.com [9.149.37.249]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u9IAe4Ol22282494 for ; Tue, 18 Oct 2016 10:40:04 GMT Received: from d06av08.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av08.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u9IAe4Tn020309 for ; Tue, 18 Oct 2016 04:40:04 -0600 References: <20161011171833.20803-1-dgilbert@redhat.com> <20161011171833.20803-4-dgilbert@redhat.com> <20161017033641.GO25390@umbus.fritz.box> <20161017190600.GF12934@work-vm> From: Halil Pasic Date: Tue, 18 Oct 2016 12:40:03 +0200 MIME-Version: 1.0 In-Reply-To: <20161017190600.GF12934@work-vm> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Message-Id: <17da19a6-ff84-3996-d73f-c0c28785639a@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [very-WIP 3/4] slirp: VMStatify sbuf List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert" Cc: David Gibson , qemu-devel@nongnu.org, amit.shah@redhat.com, quintela@redhat.com, duanj@linux.vnet.ibm.com On 10/17/2016 09:06 PM, Dr. David Alan Gilbert wrote: >> OK, memory was allocated at #2 >> > It is a bit confusing though (for a novice like me) that we have a non ALLOC VBUFFER >> > whose pointer is NULL after post_load. > I don't think this pointer can be NULL; the sbreserve at #2 causes it to be > allocated. > But yes, it's a shame I can't use VMS_ALLOC here, but the sbreserve is not > a trivial allocation function. Sorry my fault, wanted to say pre_load and not post_load. The assumption that backing memory is allocated either during device realization or in the pre_load of the parent or in vmstate_base_addr seemed a reasonable one (prior to the extra possibilities introduced by the patches of Jianjun). > >> > Now if I imagine the original stream were written in the following sequence: >> > vbuffer_length (sb_datalen), vbuffer_data (sb_data), offsets (sb_wptr, sb_rptr) >> > which seems completely valid to me then the context would not be sufficient >> > to compute sb_wptr and sb_rptr because the lifetime of vbuffer_data and >> > the tmp do not overlap. > If that was the case you could still do it pretty easily. > You'd have to add the sb_datalen and sb_data fields to the temporary > and then move the VMSTATE_VBUFFER_UINT32 into the tmp so it would operate > on the copied fields. > That basically means you expand the area affected by the tmp handling so that you have all the info you need to do the computation/transformation before the temporary is freed, right? Then the worst it can get is that you need to transform the first field and for that you need the last field. >> > I aware it's a trade-off between how long the temporary data lives and >> > how complicated the dependencies get. Or am I getting something wrong? > No, I think that's right. The other option I thought of was a macro > to allocate a temporary and then another to free it and then someway > to tell macros in between that they should operate on the temporary > rather than the main pointer; but then you'd have to be VERY careful > to not allow yourself to access a temporary that's been freed. > This structure means you can't make that mistake. > I have a couple of crazy half ideas of myself, I just do not feel very comfortable sharing them, because right now I do not have the capacity to explore them properly. Besides I don't know the code-base well enough to say if this reasoning has some practical relevance or is it 'rather academic'. Nevertheless I did not want to keep the opinion to myself that this thing with the dependencies can get rather convoluted under circumstances. Cheers, Halil > Dave > >> > >> > Cheers, >> > Halil >> > >>>> > >> + VMSTATE_END_OF_LIST() >>>> > >> + } >>>> > >> +}; >> > [..] >> >