Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2654150lqt; Mon, 22 Apr 2024 18:33:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUfLNjByMlF2mBRQokooEvH19Nzpg1/0Uutw/XhpzgbyW2rQK7Ay13EZxjvX8wGVkf/pZtOBkFr4V9pGv28wIIPeidh1avPxaGSnBMdnA== X-Google-Smtp-Source: AGHT+IEe4mCfRks8xLngFtt5fZKj5pdIKN1SIlWsR3pBcNgqi+FNg6T1NCi3XL6XLO3dEknaGyDO X-Received: by 2002:a17:903:1252:b0:1dd:5f85:118c with SMTP id u18-20020a170903125200b001dd5f85118cmr14413562plh.62.1713836014405; Mon, 22 Apr 2024 18:33:34 -0700 (PDT) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q6-20020a170902b10600b001e5c6404356si8529946plr.139.2024.04.22.18.33.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 18:33:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154393-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RiTAkqd3; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-154393-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154393-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9638028526B for ; Tue, 23 Apr 2024 01:33:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6360612E5B; Tue, 23 Apr 2024 01:33:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="RiTAkqd3" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59C293FF4 for ; Tue, 23 Apr 2024 01:33:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=198.175.65.21 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713835997; cv=fail; b=ivy6eXPmBF5K7mQ72v1Fp9MQys2yp+ffP9+sHWIvC/6RpmB+y5HVmypjpa19kZ76iaIApAzb74u71zLQrkhLAaKKuQFUgG4+bZuhW4CSVdND1xEp9vHps1zv+jthndVibHKZGm7KwBMfFzOlC4fbXs/mgJVqpD9HdNKW3zgqhK8= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713835997; c=relaxed/simple; bh=cY4J1g5vgf2oHjXbin0ZPxqSYMzD01409NeDN/M4Ib4=; h=Date:From:To:CC:Subject:Message-ID:References:Content-Type: Content-Disposition:In-Reply-To:MIME-Version; b=HFjcIz+tSe5e2hkckwUeXFz4nKCG+auhuZO4Cfwnskeo4Q9tJCTPGIYa4XPjnp68/1GfrAGdI0Q7V3B3OvXvPc1YZuB3ZgJiuJAqXgNjHBsm8eSDnxyKyrQB4YSyvYLx1QmkOMlpnWM+geScufOIaBxfekL8D18S5thv74O6jhI= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=RiTAkqd3; arc=fail smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713835994; x=1745371994; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=cY4J1g5vgf2oHjXbin0ZPxqSYMzD01409NeDN/M4Ib4=; b=RiTAkqd3jkmSHzRaI0VmDXiwm6+w9vTq/SgH84MJyxaPXickVZnPA5Vy v9VyhbIr/yZXUDbbeTtu75uznESIFJi1FXrccKLiX6Lw7dhPyn7S+EQBF SR+Mq9GDXIjX1z1Nfp5a8BT/+wNYX6E9D4OhkJg7hOqFhWPhaK5evUcII sUUkE0lGk+kgi6Q2pcm5iZqpeMMQnS14jxeTegfe3aqCvnSUeqoTwyqIc S1gSzYm6DQN+TcOfkwY4P4hcSlAa8yfRLG8z/73sDkR055E/t/QrgIb8a TUNDOGjM+UoZBkFBCR400iNuj6+4zpkiicOmRWbuRtIovt1RuZJb7ifzR g==; X-CSE-ConnectionGUID: TzQpx631T2uwIeTKr9PM3Q== X-CSE-MsgGUID: JQQ9lX8dRI6Za2f9e/zkYg== X-IronPort-AV: E=McAfee;i="6600,9927,11052"; a="9319819" X-IronPort-AV: E=Sophos;i="6.07,222,1708416000"; d="scan'208";a="9319819" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2024 18:33:14 -0700 X-CSE-ConnectionGUID: QyG7NvekQdGxHfI1YV32KQ== X-CSE-MsgGUID: PQILOsViSReHVzrccolDmg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,222,1708416000"; d="scan'208";a="61650909" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orviesa001.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 22 Apr 2024 18:33:14 -0700 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 22 Apr 2024 18:33:13 -0700 Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) by ORSMSX612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 22 Apr 2024 18:33:13 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Mon, 22 Apr 2024 18:33:13 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.100) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 22 Apr 2024 18:33:12 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bav4gxDcwcBMs+L9o8QaYZOWep73Dt63XX7+vdZxrPJP08AQayUyGafQcV/zTNHyRWpLyMw6C9exTmykTFlPWQSyPFG7MkXw2QIg5NUt7jUXupJpE+AnX9iTNG2QMh2lPs2+QtBmb3ABMPetJ78Tucp9n3DAVC7oErI/1tCy1n5MePGxST3D7DsbrWTQa0SacEBKbJ5UWatMZhY2NYyAK/nnuaygEdNi5Nrt05jEhY807xw4mVzIJMgYNnJT4OGNA/gwNTyaQop3NdfApM2N9pD7LdZ0zRq7jnjrMPleDMtFNQcWKksOoNqCj9vQfkJJ+TEMDuLz0FP9U6uv+AbMQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4L+glS4ZYwCT8nd7ILt9W9fToHRIcIO+XIoUZY7xw+4=; b=TU9rrZxLUKnbwguh80yy8YutabcqW6PrX4waZ7wFMHapDIuXn5L2IA5Rax8WQ+EL3PuZzd9XKc+vv/Jy1dKgUJ0NwcSzaR6c0ieoOvj1pn1T/YSX3LvhTbgmut66GKeTIPbkZgNvpOR34mUM8E95ci0XTlFhoFPejRspGSc6zH6i/ggG+2Q7lnpQC3H96JflnL+GV6PiA10jJklZsv5bGRfnzE4WPrRIESA4r0rOwTjtqzBMazEWF4z8dNm5h69Mr+6ZWmVbteLUJpbaaH5R/2bkWijLvswCqGgRiyURcYtotEUqJxIrvqVK+WOWJXEe4SkR8PlH1wWIfIqVsk17CQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from SA1PR11MB8393.namprd11.prod.outlook.com (2603:10b6:806:373::21) by CY5PR11MB6258.namprd11.prod.outlook.com (2603:10b6:930:25::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.21; Tue, 23 Apr 2024 01:33:10 +0000 Received: from SA1PR11MB8393.namprd11.prod.outlook.com ([fe80::c0cf:689c:129c:4bcd]) by SA1PR11MB8393.namprd11.prod.outlook.com ([fe80::c0cf:689c:129c:4bcd%6]) with mapi id 15.20.7519.018; Tue, 23 Apr 2024 01:33:10 +0000 Date: Tue, 23 Apr 2024 09:26:34 +0800 From: Yujie Liu To: Chen Yu CC: Xuewen Yan , , , , , , , , , , , , , , , Sergei Trofimovich , "Breno Leitao" , Igor Raits , Tim Chen Subject: Re: [PATCH v2] sched/eevdf: Prevent vlag from going out of bounds when reweight_eevdf Message-ID: References: <20240422082238.5784-1-xuewen.yan@unisoc.com> Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: SI1PR02CA0060.apcprd02.prod.outlook.com (2603:1096:4:1f5::17) To SA1PR11MB8393.namprd11.prod.outlook.com (2603:10b6:806:373::21) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR11MB8393:EE_|CY5PR11MB6258:EE_ X-MS-Office365-Filtering-Correlation-Id: 0f4234ab-e712-463e-8a5b-08dc633555bd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|376005|366007|1800799015; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?+ecMVvlfTQbAwULfIj27U+501Zt6IMgYAnG//DXyhap6Fu6KIfdlaIb4JAtY?= =?us-ascii?Q?hLhyltc7dOoaiYsUfFeMIM6N46UDQj8xfk2VOOe9AT/m4R2xYfo4hrsEmxyL?= =?us-ascii?Q?ewfwAaVuKVn02Y6zl7Lh+IiLMjPKS0AKx/RQ3zKv7YhtGzMj1N6QmRG6gQzS?= =?us-ascii?Q?4C7RuJwVhiS6CHHUjKZ9a1tVj+ny11tf4u09MF5xTDormU1sKY/DDIOZt2lZ?= =?us-ascii?Q?t10caPtXnInPtj31wKArVj14uof+ipmMFOPgldge+OJZCVKTXaNij4XzQPle?= =?us-ascii?Q?rGPoP/pJSmODviExl/Ntf+OxIrIOa2dWc/ORfb23K31FZ4L70D0W2hQ6YKDB?= =?us-ascii?Q?nIDeZKT5AXp670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37eyjTslMN4H0?= =?us-ascii?Q?=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR11MB8393.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(7416005)(376005)(366007)(1800799015);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?sUd2EqudohJ72j/AETG/7L6WsbyRyseo7i2IsOSFDYL+4jN7XejZq0cGShMv?= =?us-ascii?Q?tVS2uh3zxZfmtklKp4wWKCuP1WvkRCF9Qx+/VCJOSFARvUvTeKoUTnAXvreC?= =?us-ascii?Q?bjm7WpFJDUpmfDgI3j5WVySX4g6KUAPSiXrkG7hb5iiWJvPM22WZb/oQtnQX?= =?us-ascii?Q?S6Ie455YicMFd3vxy5iNb8+/f7o+/OABZUFC2PEhdFz+P1gJRu0pPWiqF1u2?= =?us-ascii?Q?Bj+ZoSkZ1enGKlorUKQjF0lK0e8dDLn34sjj/0r1G1cb1E311a39Ypggyqe1?= =?us-ascii?Q?kWqWqJAQm/Zx+KHpcI2gM4f0OvsDlxfPmILqbib7CVo33OyZThm3xoDzXkuc?= =?us-ascii?Q?VKevHXkhy0JVXlbgaeXqqVx157xtgx2R6H/dtkMRf6V1akccn5jc9VbssMbB?= =?us-ascii?Q?8T4qdhktPxEsSy8juWh2znBfatr3CYsJomMEHHJDHBJsAzjpItrBktgkYZ7c?= =?us-ascii?Q?AnUpIxdu9G7bPlEbfGavrkmE2zYfdRssF0qr8xtu1d4Rsclkvw5CCTkj+UI9?= =?us-ascii?Q?r5rZfX6Qv8A0e6VJ/7BS1LMMO8C/yeMPBVmqAvPlWEwBw4/LBHaatNjPw97m?= =?us-ascii?Q?kyOIDW6V4HoP6UgnV0a8doJSg0HXN1sG+h4tQRpbleE9zz/ZlKAbNuyjXPp1?= =?us-ascii?Q?GzXpg9xMs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TIMM1Ctud33s/bm?= =?us-ascii?Q?nmSu6iJhuEp/nGhHNbuja8c9f15OVl7P7R8PJJZP?= X-MS-Exchange-CrossTenant-Network-Message-Id: 0f4234ab-e712-463e-8a5b-08dc633555bd X-MS-Exchange-CrossTenant-AuthSource: SA1PR11MB8393.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2024 01:33:10.5543 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8TZbFkCbefBRrTD8wXU70OPlYSZTrn7Y4Yai1TaKMNGlOHI7g6JOx1ZBEFXLuEkSHkHt3UpUA6Zyyy9gAJePGg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR11MB6258 X-OriginatorOrg: intel.com On Mon, Apr 22, 2024 at 04:47:31PM +0800, Chen Yu wrote: > On 2024-04-22 at 16:22:38 +0800, Xuewen Yan wrote: > > kernel encounters the following error when running workload: > > > > BUG: kernel NULL pointer dereference, address: 0000002c > > EIP: set_next_entity (fair.c:?) > > > > which was caused by NULL pointer returned by pick_eevdf(). > > > > Further investigation has shown that, the entity_eligible() has an > > false-negative issue when the entity's vruntime is far behind the > > cfs_rq.min_vruntime that, the (vruntime - cfs_rq->min_vruntime) * load > > caused a s64 overflow, thus every entity on the rb-tree is not > > eligible, which results in a NULL candidate. > > > > The reason why entity's vruntime is far behind the cfs_rq.min_vruntime > > is because during a on_rq task group's update_cfs_group()->reweight_eevdf(), > > there is no limit on the new entity's vlag. If the new weight is much > > smaller than the old one, > > > > vlag = div_s64(vlag * old_weight, weight) > > > > generates a huge vlag, and results in very small(negative) vruntime. > > > > Thus limit the range of vlag accordingly. > > > > Thanks for the fix. > > Might also add comments from Tim suggested here: > https://lore.kernel.org/lkml/ec479251e6245148b89b226f734192f6d5343bbc.camel@linux.intel.com/ > > A fix tag might be needed. > Fixes: eab03c23c2a1 ("sched/eevdf: Fix vruntime adjustment on reweight") > > > Reported-by: Sergei Trofimovich > > Closes: https://lore.kernel.org/all/ZhuYyrh3mweP_Kd8@nz.home/ > > Reported-by: Igor Raits > > Closes: https://lore.kernel.org/all/CA+9S74ih+45M_2TPUY_mPPVDhNvyYfy1J1ftSix+KjiTVxg8nw@mail.gmail.com/ > > Reported-by: Breno Leitao > > Reported-by: kernel test robot > > Closes: https://lore.kernel.org/lkml/202401301012.2ed95df0-oliver.sang@intel.com/ > > Reported-by: Yujie Liu > > Signed-off-by: Xuewen Yan > > --- > > Cced Sergei, Igor, Breno who have encountered this NULL pointer issue before. > > From my testing, with this applied I did not see the NULL pointer exception > after running trinity for 100 cycles, so > > Reviewed-and-tested-by: Chen Yu > > thanks, > Chenyu > From 0-Day testing, with this patch applied on v6.9-rc5, we no longer see the NULL pointer issue in 999 cycles of trinity test. Tested-by: Yujie Liu ========================================================================================= tbox_group/testcase/rootfs/kconfig/compiler/runtime/group/nr_groups: vm-snb/trinity/debian-11.1-i386-20220923.cgz/i386-randconfig-004-20240122/clang-17/300s/group-03/5 commit: v6.9-rc5 v6.9-rc5+patch ("sched/eevdf: Prevent vlag from going out of bounds when reweight_eevdf") v6.9-rc5 v6.9-rc5+patch ---------------- --------------------------- fail:runs %reproduction fail:runs | | | 41:999 -4% :999 dmesg.BUG:kernel_NULL_pointer_dereference,address 24:999 -2% :999 dmesg.EIP:pick_next_task_fair 17:999 -2% :999 dmesg.EIP:set_next_entity 41:999 -4% :999 dmesg.Kernel_panic-not_syncing:Fatal_exception 41:999 -4% :999 dmesg.Oops:#[##] > > changes of v2: > > -add reported-by (suggested by ) > > -remork the changelog () > > -remove the judgement of fork (Peter) > > -remove the !on_rq case. (Peter) > > --- > > Previous discussion link: > > https://lore.kernel.org/lkml/20240226082349.302363-1-yu.c.chen@intel.com/ > > https://lore.kernel.org/all/20240130080643.1828-1-xuewen.yan@unisoc.com/ > > --- > > --- > > kernel/sched/fair.c | 18 ++++++++++++------ > > 1 file changed, 12 insertions(+), 6 deletions(-) > > > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > > index 03be0d1330a6..64826f406d6d 100644 > > --- a/kernel/sched/fair.c > > +++ b/kernel/sched/fair.c > > @@ -696,15 +696,21 @@ u64 avg_vruntime(struct cfs_rq *cfs_rq) > > * > > * XXX could add max_slice to the augmented data to track this. > > */ > > -static void update_entity_lag(struct cfs_rq *cfs_rq, struct sched_entity *se) > > +static s64 entity_lag(u64 avruntime, struct sched_entity *se) > > { > > - s64 lag, limit; > > + s64 vlag, limit; > > + > > + vlag = avruntime - se->vruntime; > > + limit = calc_delta_fair(max_t(u64, 2*se->slice, TICK_NSEC), se); > > + > > + return clamp(vlag, -limit, limit); > > +} > > > > +static void update_entity_lag(struct cfs_rq *cfs_rq, struct sched_entity *se) > > +{ > > SCHED_WARN_ON(!se->on_rq); > > - lag = avg_vruntime(cfs_rq) - se->vruntime; > > > > - limit = calc_delta_fair(max_t(u64, 2*se->slice, TICK_NSEC), se); > > - se->vlag = clamp(lag, -limit, limit); > > + se->vlag = entity_lag(avg_vruntime(cfs_rq), se); > > } > > > > /* > > @@ -3761,7 +3767,7 @@ static void reweight_eevdf(struct cfs_rq *cfs_rq, struct sched_entity *se, > > * = V - vl' > > */ > > if (avruntime != se->vruntime) { > > - vlag = (s64)(avruntime - se->vruntime); > > + vlag = entity_lag(avruntime, se); > > vlag = div_s64(vlag * old_weight, weight); > > se->vruntime = avruntime - vlag; > > } > > -- > > 2.25.1 > >