Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp2178573rdb; Sun, 21 Jan 2024 10:44:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IGGlgHeYzJ7F5Gd7q0jIuvZYW3a5ZlBMH/E0VCUOXWQF0uWI2MiG/YidSxImu0Cx3fVRUD/ X-Received: by 2002:a17:906:ff06:b0:a2a:3101:c9c7 with SMTP id zn6-20020a170906ff0600b00a2a3101c9c7mr1913831ejb.123.1705862694229; Sun, 21 Jan 2024 10:44:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705862694; cv=pass; d=google.com; s=arc-20160816; b=jwAhyuNP0I6C7nMoVHf7ZlPdfgZ1dfdTcpRtgjffh4K04hMxXc1lFUKoiwMm3kxPT7 bKTq0q+2fRejY9GqmC553x+3H+zSawjBfgVagGG7AVz3VqerYDrk01+U+YvMZ3JVZnhq OSCzZ1zJE6ucIe/e+aYc9iBrxTuBagrKrIWckQrz4hsb3m9WMeAI5KU9cSUcwU6L3D0I PjieqOAxeKpMx+PWfRs1Ls3LAb+MEKLv0V/fnbnVMpfvOnr3hgiRwHKTqMGaYCmgT3eH nOFs4dyO8VjZt1Ci+5x0S1BWgOKqeM4lYdmjjeMba2KQkNkNGiTdrbao34Lrq8Izven8 Vrgg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=guMoP2TLsfEqj1Hggx/w0+mwdRN+95oChUYRB7tzFcY=; fh=USRzoaq7mMdHOzkH5baFBruR9+z8PEcJExvyVzXHsEI=; b=fWIdCcBOj98aiAf6ahJxhpVl1UC8Mw3KgeHjC1vuRg6WQRhZQHFNkK4rZhkzODHSRK HkS5u3Kc1WCgykjVvf/etAA9v/kpPcdzotg6xxrhP6k1sWC/JIyKuHnTvatLSKwC3H11 M8hcA4M/YYDDiVZOXjfTMFjbpuOf1dakcTKLY4MuSjVnXjA1Hmhlbr8NboRTlAmRnRaM XiQ3GfrdFy7s7JoD4cZkAbZ3yNMYi3A8bLEesEC3GYnrA/OZyIRMeiX4vs/BKVNvwF+d 4/czWIMpDWNEHicbK+3EqjNLVrs2DKdE0RIPzN1EQ/eA1Xjz44HPD8FWTk7CJVWqrgGn s0LQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fkwIE3fs; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-32149-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32149-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id r18-20020a1709062cd200b00a30400c2bebsi416295ejr.574.2024.01.21.10.44.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 10:44:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32149-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fkwIE3fs; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-32149-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32149-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 am.mirrors.kernel.org (Postfix) with ESMTPS id D052E1F21777 for ; Sun, 21 Jan 2024 18:44:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C0C7B38394; Sun, 21 Jan 2024 18:44:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fkwIE3fs" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 3C847364A1 for ; Sun, 21 Jan 2024 18:44:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705862683; cv=none; b=GXXb4iGnMw2WoiJ7kAaKDPeLUnuVjjZaenteS0sTil/xcjv4BMzbbMvcuUcb+e+nStPDoDJP1DuHziVp03gOnPWsHg6vETi5DHpt0v1BF5eQsDMLpObaD9c9H4p529NTz5lvj8NzH/6IDnUsCYW2kEWgvCghsSaRF/KOwL+K6m0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705862683; c=relaxed/simple; bh=pAwTTU33ri9CTWjjk66csXD8pbCteqoL4Oh7bntQT0k=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZQyYUNSr60KtK+HdHvjXoOu/Lq3UF+EtZXsbT9fDaSDf1KLQ2IE5I7+66kAnEFUcpZ+Joxd1yhZVZKjb5LgP48wE7NErFnMAlssK1bUkBao2u0B3QDOntOQm+Kk3Khq2R/3BjkicxEwZ8w7eMMspysneB1DaGW9J5MRC0IaucBE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=fkwIE3fs; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705862681; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=guMoP2TLsfEqj1Hggx/w0+mwdRN+95oChUYRB7tzFcY=; b=fkwIE3fsYqPUJrAUjl/tXGq68rAl7Is2LgnmQT94mPow7aPsiz9QIDCKW08gu7AoDjNiO5 WDA+4mrh+nEVrDj0eBzAd8z9x1WqOCXd630FHrNQdBWMb+9fLltDtoNcz5Qzw7OEeMHF1k /hHWlipsDOq8Qq4rAFJ47NcjdfJAqc0= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-318-AFU7wdluMXalsz6oQlJ78w-1; Sun, 21 Jan 2024 13:44:39 -0500 X-MC-Unique: AFU7wdluMXalsz6oQlJ78w-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-337cfc83240so1675999f8f.3 for ; Sun, 21 Jan 2024 10:44:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705862678; x=1706467478; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=guMoP2TLsfEqj1Hggx/w0+mwdRN+95oChUYRB7tzFcY=; b=ku6+ymQ7gA2wTJaueJqs1Jpy1x11gm7seX/gsfIAN+KJ2WgrRDI1ih899/fk32+HOB hU2Zcbk/SE+7Grlfr3jmLq1QgprT/8XczlNjBRJlv1gjRIYfr312sbGaGze+LVhIpv9e l8FOGMpEl8StmMcrPkjTwngP27oqj8az3TKN01RWDj1kLDFdNPX7i7efTufQRy10GQTT I/VDYEfp61ZHySroahKvDRD2wq4n3xtpmKI5dSYBCtuAq/meh5OLlRwgnyzHqu/ZGHEv 6opYQ3jXtMs8cH97B6/VQeuCNRAhFu4W/LzQ+YVdAo4kAHO2WTnSwh23HA+EItp41mjz 6XPQ== X-Gm-Message-State: AOJu0YyyfXWUZCZoDVcX/+pduAo0WldUMkSfOLjdP+ZeuMmo50IyZCYw 9qI4WBqqbSGCRiztoEh8n2o4FtU2aTsG5DhC2mSGeAZmCvbI/qiUy1iMWy3dePV+yct98yU0852 k3c32aeIEBEVQAnXEqbcjicqVsqQt1lBQqfPxh7xyDTtP/g03q695nPRPH0w9mA== X-Received: by 2002:a05:600c:1c85:b0:40e:4789:7842 with SMTP id k5-20020a05600c1c8500b0040e47897842mr1857736wms.236.1705862678255; Sun, 21 Jan 2024 10:44:38 -0800 (PST) X-Received: by 2002:a05:600c:1c85:b0:40e:4789:7842 with SMTP id k5-20020a05600c1c8500b0040e47897842mr1857731wms.236.1705862677920; Sun, 21 Jan 2024 10:44:37 -0800 (PST) Received: from redhat.com ([2.52.14.57]) by smtp.gmail.com with ESMTPSA id t18-20020a05600c199200b0040e5951f199sm36202366wmq.34.2024.01.21.10.44.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 10:44:36 -0800 (PST) Date: Sun, 21 Jan 2024 13:44:32 -0500 From: "Michael S. Tsirkin" To: Tobias Huschle Cc: Jason Wang , Abel Wu , Peter Zijlstra , Linux Kernel , kvm@vger.kernel.org, virtualization@lists.linux.dev, netdev@vger.kernel.org Subject: Re: Re: Re: EEVDF/vhost regression (bisected to 86bfbb7ce4f6 sched/fair: Add lag based placement) Message-ID: <20240121134311-mutt-send-email-mst@kernel.org> References: <20231211115329-mutt-send-email-mst@kernel.org> <20231212111433-mutt-send-email-mst@kernel.org> <42870.123121305373200110@us-mta-641.us.mimecast.lan> <20231213061719-mutt-send-email-mst@kernel.org> <25485.123121307454100283@us-mta-18.us.mimecast.lan> <20231213094854-mutt-send-email-mst@kernel.org> <20231214021328-mutt-send-email-mst@kernel.org> <92916.124010808133201076@us-mta-622.us.mimecast.lan> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <92916.124010808133201076@us-mta-622.us.mimecast.lan> On Mon, Jan 08, 2024 at 02:13:25PM +0100, Tobias Huschle wrote: > On Thu, Dec 14, 2023 at 02:14:59AM -0500, Michael S. Tsirkin wrote: > > > > Peter, would appreciate feedback on this. When is cond_resched() > > insufficient to give up the CPU? Should Documentation/kernel-hacking/hacking.rst > > be updated to require schedule() instead? > > > > Happy new year everybody! > > I'd like to bring this thread back to life. To reiterate: > > - The introduction of the EEVDF scheduler revealed a performance > regression in a uperf testcase of ~50%. > - Tracing the scheduler showed that it takes decisions which are > in line with its design. > - The traces showed as well, that a vhost instance might run > excessively long on its CPU in some circumstance. Those cause > the performance regression as they cause delay times of 100+ms > for a kworker which drives the actual network processing. > - Before EEVDF, the vhost would always be scheduled off its CPU > in favor of the kworker, as the kworker was being woken up and > the former scheduler was giving more priority to the woken up > task. With EEVDF, the kworker, as a long running process, is > able to accumulate negative lag, which causes EEVDF to not > prefer it on its wake up, leaving the vhost running. > - If the kworker is not scheduled when being woken up, the vhost > continues looping until it is migrated off the CPU. > - The vhost offers to be scheduled off the CPU by calling > cond_resched(), but, the the need_resched flag is not set, > therefore cond_resched() does nothing. > > To solve this, I see the following options > (might not be a complete nor a correct list) > - Along with the wakeup of the kworker, need_resched needs to > be set, such that cond_resched() triggers a reschedule. Let's try this? Does not look like discussing vhost itself will draw attention from scheduler guys but posting a scheduling patch probably will? Can you post a patch? > - The vhost calls schedule() instead of cond_resched() to give up > the CPU. This would of course be a significantly stricter > approach and might limit the performance of vhost in other cases. > - Preventing the kworker from accumulating negative lag as it is > mostly not runnable and if it runs, it only runs for a very short > time frame. This might clash with the overall concept of EEVDF. > - On cond_resched(), verify if the consumed runtime of the caller > is outweighing the negative lag of another process (e.g. the > kworker) and schedule the other process. Introduces overhead > to cond_resched. Or this last one. > > I would be curious on feedback on those ideas and interested in > alternative approaches.