From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 133B8C433E2 for ; Mon, 31 Aug 2020 09:13:34 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BCF42208CA for ; Mon, 31 Aug 2020 09:13:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="vcGqfc+l" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BCF42208CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36038 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCfsa-0005Jf-UD for qemu-devel@archiver.kernel.org; Mon, 31 Aug 2020 05:13:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCfs0-0004rv-Fu for qemu-devel@nongnu.org; Mon, 31 Aug 2020 05:12:56 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:49976) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCfry-0003Fi-Iq for qemu-devel@nongnu.org; Mon, 31 Aug 2020 05:12:56 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07V8UAGU036435; Mon, 31 Aug 2020 09:12:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=to : cc : subject : in-reply-to : references : sender : from : date : message-id : mime-version : content-type; s=corp-2020-01-29; bh=dcnkMy+m1ZqaSDGgxfkNERdf9EQ4/ec3L7LCZRO4WxM=; b=vcGqfc+l/GnzpXgb34D4BWiDBy7lnwN+wT41FYqUBdhdzysNJXeV6HikxPTbRJ3AQqgC pVoRbyFVLbyUkPhIiULMC+AYdlFWvO95L7KJDiS1NaO1QGiPVleiJWxiD2L4owVv5VUb WeZgQNbUybOCzrgTWps3yyNfSuoYuWfNZvwoIKR6PxV1blfaaObX61z/ZXl9y0qlzrFB BIq6Ue0+IRHr1VV3JOKoew01MCfVxTJjSS4rF3CtXF61Rgfhn6zn1mOAciHkUvAXXKF3 mKKytr0gT3S6lLNplD1EgWiRjmhE/mUJkv+Elum5qA5F+k0b3uuNof3DKnYidTCJZjHs GQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 337eykw6sd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 31 Aug 2020 09:12:47 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07V8V7bj053081; Mon, 31 Aug 2020 09:12:46 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 3380kkcf1y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 31 Aug 2020 09:12:46 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 07V9Ckc6009902; Mon, 31 Aug 2020 09:12:46 GMT Received: from disaster-area.hh.sledj.net (/81.187.26.238) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 31 Aug 2020 02:12:46 -0700 Received: from localhost (disaster-area.hh.sledj.net [local]) by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id ed5d9b7a; Mon, 31 Aug 2020 09:12:43 +0000 (UTC) To: Chuan Zheng , quintela@redhat.com, eblake@redhat.com, dgilbert@redhat.com, berrange@redhat.com Subject: Re: [PATCH v6 09/12] migration/dirtyrate: Implement set_sample_page_period() and get_sample_page_period() In-Reply-To: <1598669577-76914-10-git-send-email-zhengchuan@huawei.com> References: <1598669577-76914-1-git-send-email-zhengchuan@huawei.com> <1598669577-76914-10-git-send-email-zhengchuan@huawei.com> X-HGTTG: heart-of-gold From: David Edmondson Date: Mon, 31 Aug 2020 10:12:43 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9729 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 adultscore=0 mlxscore=0 suspectscore=1 malwarescore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008310051 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9729 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 priorityscore=1501 phishscore=0 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 clxscore=1015 spamscore=0 bulkscore=0 impostorscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008310051 Received-SPF: pass client-ip=141.146.126.78; envelope-from=david.edmondson@oracle.com; helo=aserp2120.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 05:07:47 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: alex.chen@huawei.com, ann.zhuangyanying@huawei.com, zhang.zhanghailiang@huawei.com, xiexiangyou@huawei.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Saturday, 2020-08-29 at 10:52:54 +08, Chuan Zheng wrote: > Implement set_sample_page_period()/get_sample_page_period() to sleep > specific time between sample actions. > > Signed-off-by: Chuan Zheng > Reviewed-by: Dr. David Alan Gilbert Reviewed-by: David Edmondson > --- > migration/dirtyrate.c | 24 ++++++++++++++++++++++++ > migration/dirtyrate.h | 6 ++++++ > 2 files changed, 30 insertions(+) > > diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c > index 420fc59..850126d 100644 > --- a/migration/dirtyrate.c > +++ b/migration/dirtyrate.c > @@ -27,6 +27,30 @@ > static int CalculatingState = DIRTY_RATE_STATUS_UNSTARTED; > static struct DirtyRateStat DirtyStat; > > +static int64_t set_sample_page_period(int64_t msec, int64_t initial_time) > +{ > + int64_t current_time; > + > + current_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); > + if ((current_time - initial_time) >= msec) { > + msec = current_time - initial_time; > + } else { > + g_usleep((msec + initial_time - current_time) * 1000); > + } > + > + return msec; > +} > + > +static bool get_sample_page_period(int64_t sec) > +{ > + if (sec < MIN_FETCH_DIRTYRATE_TIME_SEC || > + sec > MAX_FETCH_DIRTYRATE_TIME_SEC) { > + return false; > + } > + > + return true; > +} > + > static int dirtyrate_set_state(int *state, int old_state, int new_state) > { > assert(new_state < DIRTY_RATE_STATUS__MAX); > diff --git a/migration/dirtyrate.h b/migration/dirtyrate.h > index faaf9da..8f9bc80 100644 > --- a/migration/dirtyrate.h > +++ b/migration/dirtyrate.h > @@ -29,6 +29,12 @@ > */ > #define MIN_RAMBLOCK_SIZE 128 > > +/* > + * Take 1s as minimum time for calculation duration > + */ > +#define MIN_FETCH_DIRTYRATE_TIME_SEC 1 > +#define MAX_FETCH_DIRTYRATE_TIME_SEC 60 > + > struct DirtyRateConfig { > uint64_t sample_pages_per_gigabytes; /* sample pages per GB */ > int64_t sample_period_seconds; /* time duration between two sampling */ > -- > 1.8.3.1 dme. -- Tonight I think I'll walk alone, I'll find my soul as I go home.