Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F2A5C636CC for ; Tue, 31 Jan 2023 10:00:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232392AbjAaKA0 (ORCPT ); Tue, 31 Jan 2023 05:00:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229934AbjAaKAT (ORCPT ); Tue, 31 Jan 2023 05:00:19 -0500 Received: from smtp-fw-6001.amazon.com (smtp-fw-6001.amazon.com [52.95.48.154]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE41A4A217 for ; Tue, 31 Jan 2023 02:00:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1675159218; x=1706695218; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=1hiqqE0Xqm1jejQpMfknaXN5n98nZOzkrcC6EzTFhHI=; b=HbUQB1gTOhhVSpAd7ukddWLohzSAOByAmAfb16L3bPDWYr81bQ+vD2GD GbX662RbAHsFetK8hFEAmahAM59burSj04weJEqZQfEn7PulCLWUQDQfr McxuTue49sZWJGrQdmnl1OrhA8N5LNCJUoa05HtMP72EepwTsZCVse11G s=; X-IronPort-AV: E=Sophos;i="5.97,261,1669075200"; d="scan'208";a="293796957" Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-iad-1d-m6i4x-25ac6bd5.us-east-1.amazon.com) ([10.43.8.2]) by smtp-border-fw-6001.iad6.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2023 10:00:13 +0000 Received: from EX13D41EUC002.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-iad-1d-m6i4x-25ac6bd5.us-east-1.amazon.com (Postfix) with ESMTPS id 4761443AC8; Tue, 31 Jan 2023 10:00:06 +0000 (UTC) Received: from EX19D033EUC004.ant.amazon.com (10.252.61.133) by EX13D41EUC002.ant.amazon.com (10.43.164.230) with Microsoft SMTP Server (TLS) id 15.0.1497.45; Tue, 31 Jan 2023 10:00:06 +0000 Received: from u40bc5e070a0153.ant.amazon.com (10.43.160.120) by EX19D033EUC004.ant.amazon.com (10.252.61.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.24; Tue, 31 Jan 2023 10:00:01 +0000 Date: Tue, 31 Jan 2023 10:59:55 +0100 From: Roman Kagan To: Chen Yu CC: Vincent Guittot , Peter Zijlstra , Zhang Qiao , Waiman Long , Ingo Molnar , Juri Lelli , Dietmar Eggemann , "Steven Rostedt" , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , lkml Subject: Re: [bug-report] possible s64 overflow in max_vruntime() Message-ID: Mail-Followup-To: Roman Kagan , Chen Yu , Vincent Guittot , Peter Zijlstra , Zhang Qiao , Waiman Long , Ingo Molnar , Juri Lelli , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , lkml References: <73e639d5-702b-0d03-16d9-a965b1963ef6@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: X-Originating-IP: [10.43.160.120] X-ClientProxiedBy: EX13D35UWB002.ant.amazon.com (10.43.161.154) To EX19D033EUC004.ant.amazon.com (10.252.61.133) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 31, 2023 at 11:21:17AM +0800, Chen Yu wrote: > On 2023-01-27 at 17:18:56 +0100, Vincent Guittot wrote: > > On Fri, 27 Jan 2023 at 12:44, Peter Zijlstra wrote: > > > > > > On Thu, Jan 26, 2023 at 07:31:02PM +0100, Roman Kagan wrote: > > > > > > > > All that only matters for small sleeps anyway. > > > > > > > > > > Something like: > > > > > > > > > > sleep_time = U64_MAX; > > > > > if (se->avg.last_update_time) > > > > > sleep_time = cfs_rq_clock_pelt(cfs_rq) - se->avg.last_update_time; > > > > > > > > Interesting, why not rq_clock_task(rq_of(cfs_rq)) - se->exec_start, as > > > > others were suggesting? It appears to better match the notion of sleep > > > > wall-time, no? > > > > > > Should also work I suppose. cfs_rq_clock takes throttling into account, > > > but that should hopefully also not be *that* long, so either should > > > work. > > > > yes rq_clock_task(rq_of(cfs_rq)) should be fine too > > > > Another thing to take into account is the sleeper credit that the > > waking task deserves so the detection should be done once it has been > > subtracted from vruntime. > > > > Last point, when a nice -20 task runs on a rq, it will take a bit more > > than 2 seconds for the vruntime to be increased by more than 24ms (the > > maximum credit that a waking task can get) so threshold must be > > significantly higher than 2 sec. On the opposite side, the lowest > > possible weight of a cfs rq is 2 which means that the problem appears > > for a sleep longer or equal to 2^54 = 2^63*2/1024. We should use this > > value instead of an arbitrary 200 days > Does it mean any threshold between 2 sec and 2^54 nsec should be fine? Because > 1. Any task sleeps longer than 2 sec will get at most 24 ms(sysctl_sched_latency) > 'vruntime bonus' when enqueued. > 2. Although a low weight cfs rq run for 2^54 nsec could trigger the overflow, > we can choose threshold lower than 2^54 to avoid any overflow. This matches my understanding too, so I went ahead with the value proposed by Peter (1 min) which looked sufficiently far away from either side. Roman. Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879