From nobody Thu May 2 01:34:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528208701356870.6245760250812; Tue, 5 Jun 2018 07:25:01 -0700 (PDT) Received: from localhost ([::1]:47131 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQCtQ-00017N-Ct for importer@patchew.org; Tue, 05 Jun 2018 10:25:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQCoI-0005PW-KB for qemu-devel@nongnu.org; Tue, 05 Jun 2018 10:19:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQCoH-0002uH-O2 for qemu-devel@nongnu.org; Tue, 05 Jun 2018 10:19:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59450) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fQCoC-0002ql-SL; Tue, 05 Jun 2018 10:19:36 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 289C830BE9D0; Tue, 5 Jun 2018 14:19:36 +0000 (UTC) Received: from localhost (ovpn-116-175.phx2.redhat.com [10.3.116.175]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0ABD4608F0; Tue, 5 Jun 2018 14:19:34 +0000 (UTC) From: Jeff Cody To: qemu-block@nongnu.org Date: Tue, 5 Jun 2018 10:19:32 -0400 Message-Id: <20180605141933.30169-2-jcody@redhat.com> In-Reply-To: <20180605141933.30169-1-jcody@redhat.com> References: <20180605141933.30169-1-jcody@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Tue, 05 Jun 2018 14:19:36 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/2] sheepdog: cleanup repeated expression X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, jcody@redhat.com, qemu-devel@nongnu.org, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini The expression "SD_INODE_SIZE - sizeof(inode.data_vdi_id)" already has a ma= cro defined for the same value (though with a nicer definition using offsetof). Replace it. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Fam Zheng Reviewed-by: Jeff Cody Signed-off-by: Paolo Bonzini Message-Id: <20180523160721.14018-2-pbonzini@redhat.com> Signed-off-by: Jeff Cody --- block/sheepdog.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/sheepdog.c b/block/sheepdog.c index 2a5bc0a59a..cfc0e28aa5 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -2335,7 +2335,7 @@ static int sd_truncate(BlockDriverState *bs, int64_t = offset, } =20 /* we don't need to update entire object */ - datalen =3D SD_INODE_SIZE - sizeof(s->inode.data_vdi_id); + datalen =3D SD_INODE_HEADER_SIZE; s->inode.vdi_size =3D offset; ret =3D write_object(fd, s->bs, (char *)&s->inode, vid_to_vdi_oid(s->inode.vdi_id), s->inode.nr_copies, @@ -2703,7 +2703,7 @@ static int sd_snapshot_create(BlockDriverState *bs, Q= EMUSnapshotInfo *sn_info) */ strncpy(s->inode.tag, sn_info->name, sizeof(s->inode.tag)); /* we don't need to update entire object */ - datalen =3D SD_INODE_SIZE - sizeof(s->inode.data_vdi_id); + datalen =3D SD_INODE_HEADER_SIZE; inode =3D g_malloc(datalen); =20 /* refresh inode. */ @@ -2989,7 +2989,7 @@ static int sd_snapshot_list(BlockDriverState *bs, QEM= USnapshotInfo **psn_tab) /* we don't need to read entire object */ ret =3D read_object(fd, s->bs, (char *)&inode, vid_to_vdi_oid(vid), - 0, SD_INODE_SIZE - sizeof(inode.data_vdi_id), 0, + 0, SD_INODE_HEADER_SIZE, 0, s->cache_flags); =20 if (ret) { --=20 2.13.6 From nobody Thu May 2 01:34:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528208498237708.5252083297538; Tue, 5 Jun 2018 07:21:38 -0700 (PDT) Received: from localhost ([::1]:47092 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQCq9-0006b4-B4 for importer@patchew.org; Tue, 05 Jun 2018 10:21:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQCoI-0005Pf-RY for qemu-devel@nongnu.org; Tue, 05 Jun 2018 10:19:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQCoH-0002uQ-TH for qemu-devel@nongnu.org; Tue, 05 Jun 2018 10:19:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33816) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fQCoD-0002rw-Pe; Tue, 05 Jun 2018 10:19:37 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0E6777DA3F; Tue, 5 Jun 2018 14:19:37 +0000 (UTC) Received: from localhost (ovpn-116-175.phx2.redhat.com [10.3.116.175]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CCDF81062246; Tue, 5 Jun 2018 14:19:36 +0000 (UTC) From: Jeff Cody To: qemu-block@nongnu.org Date: Tue, 5 Jun 2018 10:19:33 -0400 Message-Id: <20180605141933.30169-3-jcody@redhat.com> In-Reply-To: <20180605141933.30169-1-jcody@redhat.com> References: <20180605141933.30169-1-jcody@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 05 Jun 2018 14:19:37 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/2] sheepdog: remove huge BSS object X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, jcody@redhat.com, qemu-devel@nongnu.org, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini block/sheepdog.o has a 4M static variable that is 90% of QEMU's whole .bss section. Replace it with a heap-allocated block, and make it smaller too since only the inode header is actually being used. bss size goes down from 4464280 to 269976. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Jeff Cody Signed-off-by: Paolo Bonzini Message-Id: <20180523160721.14018-3-pbonzini@redhat.com> Signed-off-by: Jeff Cody --- block/sheepdog.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/block/sheepdog.c b/block/sheepdog.c index cfc0e28aa5..7b98725af7 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -2938,13 +2938,14 @@ static int sd_snapshot_list(BlockDriverState *bs, Q= EMUSnapshotInfo **psn_tab) QEMUSnapshotInfo *sn_tab =3D NULL; unsigned wlen, rlen; int found =3D 0; - static SheepdogInode inode; + SheepdogInode *inode; unsigned long *vdi_inuse; unsigned int start_nr; uint64_t hval; uint32_t vid; =20 vdi_inuse =3D g_malloc(max); + inode =3D g_malloc(SD_INODE_HEADER_SIZE); =20 fd =3D connect_to_sdog(s, &local_err); if (fd < 0) { @@ -2987,7 +2988,7 @@ static int sd_snapshot_list(BlockDriverState *bs, QEM= USnapshotInfo **psn_tab) } =20 /* we don't need to read entire object */ - ret =3D read_object(fd, s->bs, (char *)&inode, + ret =3D read_object(fd, s->bs, (char *)inode, vid_to_vdi_oid(vid), 0, SD_INODE_HEADER_SIZE, 0, s->cache_flags); @@ -2996,17 +2997,17 @@ static int sd_snapshot_list(BlockDriverState *bs, Q= EMUSnapshotInfo **psn_tab) continue; } =20 - if (!strcmp(inode.name, s->name) && is_snapshot(&inode)) { - sn_tab[found].date_sec =3D inode.snap_ctime >> 32; - sn_tab[found].date_nsec =3D inode.snap_ctime & 0xffffffff; - sn_tab[found].vm_state_size =3D inode.vm_state_size; - sn_tab[found].vm_clock_nsec =3D inode.vm_clock_nsec; + if (!strcmp(inode->name, s->name) && is_snapshot(inode)) { + sn_tab[found].date_sec =3D inode->snap_ctime >> 32; + sn_tab[found].date_nsec =3D inode->snap_ctime & 0xffffffff; + sn_tab[found].vm_state_size =3D inode->vm_state_size; + sn_tab[found].vm_clock_nsec =3D inode->vm_clock_nsec; =20 snprintf(sn_tab[found].id_str, sizeof(sn_tab[found].id_str), - "%" PRIu32, inode.snap_id); + "%" PRIu32, inode->snap_id); pstrcpy(sn_tab[found].name, - MIN(sizeof(sn_tab[found].name), sizeof(inode.tag)), - inode.tag); + MIN(sizeof(sn_tab[found].name), sizeof(inode->tag)), + inode->tag); found++; } } @@ -3016,6 +3017,7 @@ out: *psn_tab =3D sn_tab; =20 g_free(vdi_inuse); + g_free(inode); =20 if (ret < 0) { return ret; --=20 2.13.6