From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="b1ISzpPV" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4724E8 for ; Wed, 13 Dec 2023 23:15:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702538107; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vRaJaBGglr58sTQWQMVIiejNzndVXiVSrMNWKcapZYU=; b=b1ISzpPVDfN8HBVeRnXludRbdLuybfmt7npNef2mz17XLC+sIpDOLu0peqmXyd1fHMtx7t lMWQLT/bPJLKn2Ssfl/jTVqOHkVaaPGXinzOfKSkHd+idd9QzLuDtGnRgBjVIpt5reqZ3S 0nQUqXpN/PtOcZUwL9zqxtE3POsQtqo= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-617-C0_F_8_7NSmRzSeqqjKwyA-1; Thu, 14 Dec 2023 02:15:05 -0500 X-MC-Unique: C0_F_8_7NSmRzSeqqjKwyA-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a1bd7a5931eso423617266b.3 for ; Wed, 13 Dec 2023 23:15:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702538104; x=1703142904; h=in-reply-to:content-transfer-encoding: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=vRaJaBGglr58sTQWQMVIiejNzndVXiVSrMNWKcapZYU=; b=ZK4dCuglFGWnwMzXEJlb83kpY4FVhTpd8HS92lvKwSxNdvKjshzYTCzRJBp5pU3YOa oZxBXZK2qtY/VVedLLBJpi/3VpEHlgtx2wjRZ9rKPRzpecoGjMjOHP7iDmT8USJfgg3M wETGthaQXs+OPds62fg7fcmKx+RWn4LS3ZujcCP1phbaf+005IjrJlrQYuLA+EUbioPC u/oeZ5TddkSrFj1LwNyftsvv9LjTXxbp+glU4wR00ylkJdQ5J6ksgla/KXzyEXeUnhR/ jTjItl0yawlKX6R8hHiTTcC0wC5H5FGiYufCASRFB21PxdYsPqTRdMs0+T1NzKvPVCya QhaQ== X-Gm-Message-State: AOJu0YxyieQ1ok4p6IZkYW598m6xG7s/uLJYVcLzS6nQCzu63W6eaBzm pQfw/zd5HmW1iEfO+W8iwwwWpn7e8Ow2K/fF2zVWbqNC7kck/+v4GiDjg0DSjLn9VMlw4SF9TG0 e2Dr8cf9dg9cVPQ2E X-Received: by 2002:a17:907:9150:b0:a1d:5864:9471 with SMTP id l16-20020a170907915000b00a1d58649471mr3654531ejs.131.1702538104441; Wed, 13 Dec 2023 23:15:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IEWMkmj5x4pGRiF3eBg98WEH/O85pbvq4edeImvdFfJoL9RengQ8lWWzDOAG01wA77QaoZCrA== X-Received: by 2002:a17:907:9150:b0:a1d:5864:9471 with SMTP id l16-20020a170907915000b00a1d58649471mr3654523ejs.131.1702538104099; Wed, 13 Dec 2023 23:15:04 -0800 (PST) Received: from redhat.com ([2.52.132.243]) by smtp.gmail.com with ESMTPSA id li14-20020a170907198e00b00a1f738318a5sm8388046ejc.155.2023.12.13.23.15.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 23:15:03 -0800 (PST) Date: Thu, 14 Dec 2023 02:14:59 -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: <20231214021328-mutt-send-email-mst@kernel.org> References: <53044.123120806415900549@us-mta-342.us.mimecast.lan> <20231209053443-mutt-send-email-mst@kernel.org> <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> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231213094854-mutt-send-email-mst@kernel.org> On Wed, Dec 13, 2023 at 09:55:23AM -0500, Michael S. Tsirkin wrote: > On Wed, Dec 13, 2023 at 01:45:35PM +0100, Tobias Huschle wrote: > > On Wed, Dec 13, 2023 at 07:00:53AM -0500, Michael S. Tsirkin wrote: > > > On Wed, Dec 13, 2023 at 11:37:23AM +0100, Tobias Huschle wrote: > > > > On Tue, Dec 12, 2023 at 11:15:01AM -0500, Michael S. Tsirkin wrote: > > > > > On Tue, Dec 12, 2023 at 11:00:12AM +0800, Jason Wang wrote: > > > > > > On Tue, Dec 12, 2023 at 12:54 AM Michael S. Tsirkin wrote: > > > > [...] > > > > > > Apparently schedule is already called? > > > > > > > What about this: > > > > static int vhost_task_fn(void *data) > > { > > <...> > > did_work = vtsk->fn(vtsk->data); --> this calls vhost_worker if I'm not mistaken > > if (!did_work) > > schedule(); > > <...> > > } > > > > static bool vhost_worker(void *data) > > { > > struct vhost_worker *worker = data; > > struct vhost_work *work, *work_next; > > struct llist_node *node; > > > > node = llist_del_all(&worker->work_list); > > if (node) { > > <...> > > llist_for_each_entry_safe(work, work_next, node, node) { > > <...> > > } > > } > > > > return !!node; > > } > > > > The llist_for_each_entry_safe does not actually change the node value, doesn't it? > > > > If it does not change it, !!node would return 1. > > Thereby skipping the schedule. > > > > This was changed recently with: > > f9010dbdce91 fork, vhost: Use CLONE_THREAD to fix freezer/ps regression > > > > It returned a hardcoded 0 before. The commit message explicitly mentions this > > change to make vhost_worker return 1 if it did something. > > > > Seems indeed like a nasty little side effect caused by EEVDF not scheduling > > the woken up kworker right away. > > > So we are actually making an effort to be nice. > Documentation/kernel-hacking/hacking.rst says: > > If you're doing longer computations: first think userspace. If you > **really** want to do it in kernel you should regularly check if you need > to give up the CPU (remember there is cooperative multitasking per CPU). > Idiom:: > > cond_resched(); /* Will sleep */ > > > and this is what vhost.c does. > > At this point I'm not sure why it's appropriate to call schedule() as opposed to > cond_resched(). Ideas? > 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? > -- > MST