From nobody Fri May 17 10:44:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1570210819; cv=none; d=zoho.com; s=zohoarc; b=nSw42DHFL+oKzVtGwp054Ha5J7YiUNJ/mwDTAdDoUUoORTvQgrtxfti59NJnrW2a1QfEDdm/GenBBu5C1fPP1pUDhvaP6feG/CBPeMATdU2dBtyASaPPGugO1WqhlctH02F5PcWdkZtDHcIQGmSE2r++QXK0RMMXTfQhcQ3M340= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570210819; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=JJhBJOXygoU9CksNvydBweP1mrlKWhv6lwLXupX/Tzo=; b=HfymE95Vcz7/IoGROZ3tfteP6/hmum0pMR/BREjAWqxDghBT3XAr4UoD1KNsDY/ZLay+JhcULKi+fZG5Jh1ZiJPwb1sc+oN3K1N8CbqryL7deud/xTvxD/+gGRivc1c9zzwO3bnc7kBwODN/xiz7JfHrPF2wtgbTahTq4lbO09M= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1570210819632878.4597347363637; Fri, 4 Oct 2019 10:40:19 -0700 (PDT) Received: from localhost ([::1]:50822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGRYp-0003iH-Sl for importer@patchew.org; Fri, 04 Oct 2019 13:40:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55233) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGRSO-0007mj-RF for qemu-devel@nongnu.org; Fri, 04 Oct 2019 13:33:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iGRSK-0006YW-0Y for qemu-devel@nongnu.org; Fri, 04 Oct 2019 13:33:30 -0400 Received: from cmccmta2.chinamobile.com ([221.176.66.80]:2632) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iGRSG-0006TK-8b for qemu-devel@nongnu.org; Fri, 04 Oct 2019 13:33:25 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.19]) by rmmx-syy-dmz-app08-12008 (RichMail) with SMTP id 2ee85d97824f008-b8d39; Sat, 05 Oct 2019 01:33:04 +0800 (CST) Received: from maozy-host.lan (unknown[180.108.8.156]) by rmsmtp-syy-appsvr10-12010 (RichMail) with SMTP id 2eea5d978248272-cd7eb; Sat, 05 Oct 2019 01:33:04 +0800 (CST) X-RM-TRANSID: 2ee85d97824f008-b8d39 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 X-RM-TRANSID: 2eea5d978248272-cd7eb From: Mao Zhongyi To: qemu-devel@nongnu.org Subject: [PATCH v4 1/3] tests/migration: mem leak fix Date: Sat, 5 Oct 2019 01:32:48 +0800 Message-Id: <95ceba2addaa3136db8ee233ea2e0ff9d13db7c0.1570208781.git.maozhongyi@cmss.chinamobile.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 221.176.66.80 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tony.nguyen@bt.com, alex.bennee@linaro.org, armbru@redhat.com, Mao Zhongyi , laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" =E2=80=98data=E2=80=99 has the possibility of memory leaks=EF=BC=8C so use = the glib macros g_autofree recommended by CODING_STYLE.rst to automatically release the memory that returned from g_malloc(). Signed-off-by: Mao Zhongyi Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Laurent Vivier --- tests/migration/stress.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/tests/migration/stress.c b/tests/migration/stress.c index d9aa4afe92..d8a6f64af0 100644 --- a/tests/migration/stress.c +++ b/tests/migration/stress.c @@ -170,26 +170,14 @@ static unsigned long long now(void) static int stressone(unsigned long long ramsizeMB) { size_t pagesPerMB =3D 1024 * 1024 / PAGE_SIZE; - char *ram =3D malloc(ramsizeMB * 1024 * 1024); + g_autofree char *ram =3D g_malloc(ramsizeMB * 1024 * 1024); char *ramptr; size_t i, j, k; - char *data =3D malloc(PAGE_SIZE); + g_autofree char *data =3D g_malloc(PAGE_SIZE); char *dataptr; size_t nMB =3D 0; unsigned long long before, after; =20 - if (!ram) { - fprintf(stderr, "%s (%05d): ERROR: cannot allocate %llu MB of RAM:= %s\n", - argv0, gettid(), ramsizeMB, strerror(errno)); - return -1; - } - if (!data) { - fprintf(stderr, "%s (%d): ERROR: cannot allocate %d bytes of RAM: = %s\n", - argv0, gettid(), PAGE_SIZE, strerror(errno)); - free(ram); - return -1; - } - /* We don't care about initial state, but we do want * to fault it all into RAM, otherwise the first iter * of the loop below will be quite slow. We cna't use @@ -198,8 +186,6 @@ static int stressone(unsigned long long ramsizeMB) memset(ram, 0xfe, ramsizeMB * 1024 * 1024); =20 if (random_bytes(data, PAGE_SIZE) < 0) { - free(ram); - free(data); return -1; } =20 @@ -227,9 +213,6 @@ static int stressone(unsigned long long ramsizeMB) } } } - - free(data); - free(ram); } =20 =20 --=20 2.17.1 From nobody Fri May 17 10:44:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1570210638; cv=none; d=zoho.com; s=zohoarc; b=mRtmzlFzNuNeUwrl6NfOU0+rrE262DshbdWhcgrz5QOhBz59nw6O7bkgEyWr1IMfGVfKUYfSJCNBAgyX0thDrVrJbU2uNtSt67vP7RpFpOcauv9prmTzvmVe5bSWfbtYkAJDh2CCfQxwuPxECzDhFUI5RZ6XCfY8uDe+7T1VRi0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570210638; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Q0ibUQNbVr9/hid/PTtHfUKfNbfIcsZTHXRE7NpiCQA=; b=Elr6R8WB8z5WSys0bTzeaeuzuUzm4g+TxvfexYpkfulZwUtEsni6TqZvXXaLtWmAfd5ZUSrMkIeIBgAkqx5qejhgiZnPUdN+G3vpGpr9MgacoK1M0XQfa+U0hMQn5x9fw8kKJyqLHs0aH+WvN4lU7Qhs7ogZVAjPJbyXi50L/8w= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1570210637116838.3613805284641; Fri, 4 Oct 2019 10:37:17 -0700 (PDT) Received: from localhost ([::1]:50806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGRVw-0001FD-VV for importer@patchew.org; Fri, 04 Oct 2019 13:37:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55234) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGRSO-0007mk-Rk for qemu-devel@nongnu.org; Fri, 04 Oct 2019 13:33:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iGRSK-0006Ye-0h for qemu-devel@nongnu.org; Fri, 04 Oct 2019 13:33:30 -0400 Received: from cmccmta3.chinamobile.com ([221.176.66.81]:9576) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iGRSG-0006Rb-H7 for qemu-devel@nongnu.org; Fri, 04 Oct 2019 13:33:26 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.19]) by rmmx-syy-dmz-app12-12012 (RichMail) with SMTP id 2eec5d97825002c-b8ec1; Sat, 05 Oct 2019 01:33:05 +0800 (CST) Received: from maozy-host.lan (unknown[180.108.8.156]) by rmsmtp-syy-appsvr10-12010 (RichMail) with SMTP id 2eea5d978248272-cd7ed; Sat, 05 Oct 2019 01:33:05 +0800 (CST) X-RM-TRANSID: 2eec5d97825002c-b8ec1 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 X-RM-TRANSID: 2eea5d978248272-cd7ed From: Mao Zhongyi To: qemu-devel@nongnu.org Subject: [PATCH v4 2/3] tests/migration: fix a typo in comment Date: Sat, 5 Oct 2019 01:32:49 +0800 Message-Id: <1d0aa8142a10edf735dac0a3330c46e98b06e8eb.1570208781.git.maozhongyi@cmss.chinamobile.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 In-Reply-To: References: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 221.176.66.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tony.nguyen@bt.com, alex.bennee@linaro.org, armbru@redhat.com, Mao Zhongyi , laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Mao Zhongyi Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tests/migration/stress.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/migration/stress.c b/tests/migration/stress.c index d8a6f64af0..f9626d50ee 100644 --- a/tests/migration/stress.c +++ b/tests/migration/stress.c @@ -180,7 +180,7 @@ static int stressone(unsigned long long ramsizeMB) =20 /* We don't care about initial state, but we do want * to fault it all into RAM, otherwise the first iter - * of the loop below will be quite slow. We cna't use + * of the loop below will be quite slow. We can't use * 0x0 as the byte as gcc optimizes that away into a * calloc instead :-) */ memset(ram, 0xfe, ramsizeMB * 1024 * 1024); --=20 2.17.1 From nobody Fri May 17 10:44:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1570210641; cv=none; d=zoho.com; s=zohoarc; b=i4k0Y6LFI2Jnrg3hTAQugIZD0xVlTJ1hnMf5lddHJ+wHWxePCEZCnlHG/28iFll0BFkxFZrsK/FCUMcUW2cr7mBe+jvQdrKyvLH2qNyHKFhmMiSFqv1VYd5Oh/qlK1Zsyaz+plrGYz5AsIkZ9M8rTPPYIn2KZhMaVaRBw40ixAQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570210641; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=30/KD8hT3VlaLaa2dsuwQM957jhWTlNkic9WDClyCWo=; b=acDu4GjLDevhh0rV3dyqeoZSiPZd9I9gDwVprh+dvXHCoeQtPQr6IgjPB+Ho4lDzFGkAGebMUwhNQMqahRoVPem0OrYNDtdmI9QBU/IX/3YOjsj9+xyYcQCJDSP42MbbeawaU1bd6TL5AAvpU1kM0PDBedmcOkTmI58eDD7lLF8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1570210640759103.44901682663385; Fri, 4 Oct 2019 10:37:20 -0700 (PDT) Received: from localhost ([::1]:50808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGRW0-0001Fz-M0 for importer@patchew.org; Fri, 04 Oct 2019 13:37:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55257) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGRSU-0007nb-Lb for qemu-devel@nongnu.org; Fri, 04 Oct 2019 13:33:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iGRSR-0006co-Dw for qemu-devel@nongnu.org; Fri, 04 Oct 2019 13:33:37 -0400 Received: from cmccmta3.chinamobile.com ([221.176.66.81]:2375) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iGRSP-0006a8-0L for qemu-devel@nongnu.org; Fri, 04 Oct 2019 13:33:34 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.19]) by rmmx-syy-dmz-app10-12010 (RichMail) with SMTP id 2eea5d97825004a-b8e93; Sat, 05 Oct 2019 01:33:06 +0800 (CST) Received: from maozy-host.lan (unknown[180.108.8.156]) by rmsmtp-syy-appsvr10-12010 (RichMail) with SMTP id 2eea5d978248272-cd7f0; Sat, 05 Oct 2019 01:33:05 +0800 (CST) X-RM-TRANSID: 2eea5d97825004a-b8e93 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 X-RM-TRANSID: 2eea5d978248272-cd7f0 From: Mao Zhongyi To: qemu-devel@nongnu.org Subject: [PATCH v4 3/3] =?UTF-8?q?tests/migration=EF=BC=9Afix=20unreachabl?= =?UTF-8?q?e=20path=20in=20stress=20test?= Date: Sat, 5 Oct 2019 01:32:50 +0800 Message-Id: <8e28cb658bc89a14958e1a7e1073f8cda4349019.1570208781.git.maozhongyi@cmss.chinamobile.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 221.176.66.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tony.nguyen@bt.com, alex.bennee@linaro.org, armbru@redhat.com, Mao Zhongyi , laurent@vivier.eu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" If stressone() or stress() exits it's because of a failure because the test runs forever otherwise, so change stressone and stress type to void to make the exit_failure() as the exit function of main(). Signed-off-by: Mao Zhongyi Reviewed-by: Laurent Vivier --- tests/migration/stress.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/migration/stress.c b/tests/migration/stress.c index f9626d50ee..a062ef6b55 100644 --- a/tests/migration/stress.c +++ b/tests/migration/stress.c @@ -167,7 +167,7 @@ static unsigned long long now(void) return (tv.tv_sec * 1000ull) + (tv.tv_usec / 1000ull); } =20 -static int stressone(unsigned long long ramsizeMB) +static void stressone(unsigned long long ramsizeMB) { size_t pagesPerMB =3D 1024 * 1024 / PAGE_SIZE; g_autofree char *ram =3D g_malloc(ramsizeMB * 1024 * 1024); @@ -186,7 +186,7 @@ static int stressone(unsigned long long ramsizeMB) memset(ram, 0xfe, ramsizeMB * 1024 * 1024); =20 if (random_bytes(data, PAGE_SIZE) < 0) { - return -1; + return; } =20 before =3D now(); @@ -225,7 +225,7 @@ static void *stressthread(void *arg) return NULL; } =20 -static int stress(unsigned long long ramsizeGB, int ncpus) +static void stress(unsigned long long ramsizeGB, int ncpus) { size_t i; unsigned long long ramsizeMB =3D ramsizeGB * 1024 / ncpus; @@ -238,8 +238,6 @@ static int stress(unsigned long long ramsizeGB, int ncp= us) } =20 stressone(ramsizeMB); - - return 0; } =20 =20 @@ -335,8 +333,7 @@ int main(int argc, char **argv) fprintf(stdout, "%s (%05d): INFO: RAM %llu GiB across %d CPUs\n", argv0, gettid(), ramsizeGB, ncpus); =20 - if (stress(ramsizeGB, ncpus) < 0) - exit_failure(); + stress(ramsizeGB, ncpus); =20 - exit_success(); + exit_failure(); } --=20 2.17.1