Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp938053yba; Thu, 9 May 2019 08:13:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqwcObaWaagqOKWH4eriTK9Xe7Eudo8r+gNE307D/Tvwn8V6GBRG0A2XwMdJtktzoOv6h/vH X-Received: by 2002:a63:3dcf:: with SMTP id k198mr6357201pga.60.1557414789499; Thu, 09 May 2019 08:13:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557414789; cv=none; d=google.com; s=arc-20160816; b=Tw70tkagOr807p0XJSE1wP37Gf0hVcM5Gf4Pgd7RgCOFZ7ugwkTcPtavf++iHUwqmO ELwFpGICokcQnfKQvwvtGs7R1vgkuKxuNEuBJrTtMngfqoPE4m/ufXa/YLiQIUGt/e8M AwCQ+7MPWS89cnen2JiT2UHzN2Fy0Wkbd6lqOKxm9ogqWFvA6UYGjz1ZcZSNhEABR55q NX6y8MYQ+D1dcMx7jEgpcAm+BfG27JumMVp6VwP4aZm6rq8IvOfSEf7SPJ1phFXz71Xz EDFVh7+mCtq4C1o8ql2WeoJxr3YzA20cySzhftD8hgGqWoaeFyNLAC+lfCggxscFufGT BCjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=8zrXFiM8h3BM6S1gXy5W3yZtlj9Py52rPJo7Mb9GqDM=; b=vN48etY9CrsZ8Rutw907zpqxnmtn73yaEsexdEHpyJ7BpYavNI0KEY4kTu96Ersj/8 GF8OPHeuG0Ane37vKugaR/vUR42HmnExfHQV6YDtWByW83PvKDjV/BgxdehVyth/rYmf Af0xdv+fjqtM9yWEWQI2xWN2V+wbXJD8Bzk78GfcQViNOP04g5kSFHP2OVGecvqHXjWB IftUzUaJ0VwTaG+BRsTx73x151W/j7dtEw20Ohn2OZTksbPzJdKDrnROFzKDbFKdPmgO FEFJ45oM1Ff0FSUj3DWX6d1Pir8iNnqxUQCfyxM4BRznutZ9NfqzNYqow56u0iyL3+p7 TmZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bKrIbVPg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 76si3721261pgf.582.2019.05.09.08.12.51; Thu, 09 May 2019 08:13:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bKrIbVPg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726787AbfEIPKT (ORCPT + 99 others); Thu, 9 May 2019 11:10:19 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:41844 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726234AbfEIPKT (ORCPT ); Thu, 9 May 2019 11:10:19 -0400 Received: by mail-lj1-f194.google.com with SMTP id k8so2319813lja.8 for ; Thu, 09 May 2019 08:10:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8zrXFiM8h3BM6S1gXy5W3yZtlj9Py52rPJo7Mb9GqDM=; b=bKrIbVPgETMiXG9sO1lXBqp+ddiU8CfZuxH+fBMswjhuffssq39cjq0l9sDUr25z13 moseLaLzu5aN5IPhqOO3Wfi5d4FtcLhEhJrk2nJX63hVINl+qd3nGSA97x0pw+0a6jTz /R3/cK7uAJTdzD7vRqKrX51jA6WH6zv/N2cT0YurLm+PBqOay9sjj1XiPR4Y3QV2ywOR rGinew7c6GpH/5CwHI63gYPqVY6j33yJKK49PfVFfUQSEMbyiEN+0Yc9rsR+si2Nl6jm 6xJglVPaJGk4XI2h7u2/YiGO3bYwWxyJX/S2TzK8O43eKjG8njUaMnh/ar6AVPB9nFwc o7lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8zrXFiM8h3BM6S1gXy5W3yZtlj9Py52rPJo7Mb9GqDM=; b=AqRd0KRxBHzm8K+6EMSUU6WHCO6DAr2hcOFQq1DQO+oRHnCNJB0w+cHJy40ieqJt42 pSWrYWYPQIIFbgp4EQsYCZCOjciyLS/pe9jVWS3Pr3+kbH/ZUL5DSL/wvih+0eXR6lB7 wZkYWIbLh1QTq23+48gRR2NWR0NYsX79eWi+z4R6Jt9/cxsJgZbt+oe0t4q3i0aKUZoW WXq7uxBcAL1cdRU9WlYbxHWxLwWqbn+h1ky8lgLRUYROSJ/1rdurJaPpb5YSivEZ9C/C +gchZISEsoAfX3Z8CjcBmlhfVanzIaimTX8QPe6HPIcyVQuTEu2h3iwB7PbxYw0kb4/3 ltjw== X-Gm-Message-State: APjAAAVXAuFbv6mnQyP6M5AQdczXCkoMsi3egmsTIzSIWZ+IAz2vDhUj j5Ky+T5Hc0P8iEpAlf9gXmo5FXdrhD2tgGKc16c= X-Received: by 2002:a2e:9a54:: with SMTP id k20mr2445973ljj.168.1557414616138; Thu, 09 May 2019 08:10:16 -0700 (PDT) MIME-Version: 1.0 References: <2364f2b65bf50826d881c84d7634b6565dfee527.1556025155.git.vpillai@digitalocean.com> <20190429061516.GA9796@aaronlu> <6dfc392f-e24b-e641-2f7d-f336a90415fa@linux.intel.com> <777b7674-4811-dac4-17df-29bd028d6b26@linux.intel.com> <28fb6854-2772-5d29-087a-6a0cf6afe626@oracle.com> <8098b70b-2095-91ea-d4ad-9181829066c7@oracle.com> <7671d3f0-ca07-7260-a855-473ab58d1c30@oracle.com> In-Reply-To: <7671d3f0-ca07-7260-a855-473ab58d1c30@oracle.com> From: Aubrey Li Date: Thu, 9 May 2019 23:10:04 +0800 Message-ID: Subject: Re: [RFC PATCH v2 11/17] sched: Basic tracking of matching tasks To: Subhra Mazumdar Cc: Tim Chen , Aaron Lu , Vineeth Remanan Pillai , Nishanth Aravamudan , Julien Desfossez , Peter Zijlstra , Ingo Molnar , Thomas Gleixner , Paul Turner , Linus Torvalds , Linux List Kernel Mailing , =?UTF-8?B?RnLDqWTDqXJpYyBXZWlzYmVja2Vy?= , Kees Cook , Greg Kerr , Phil Auld , Aaron Lu , Valentin Schneider , Mel Gorman , Pawan Gupta , Paolo Bonzini Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 9, 2019 at 10:14 AM Subhra Mazumdar wrote: > > > On 5/8/19 6:38 PM, Aubrey Li wrote: > > On Thu, May 9, 2019 at 8:29 AM Subhra Mazumdar > > wrote: > >> > >> On 5/8/19 5:01 PM, Aubrey Li wrote: > >>> On Thu, May 9, 2019 at 2:41 AM Subhra Mazumdar > >>> wrote: > >>>> On 5/8/19 11:19 AM, Subhra Mazumdar wrote: > >>>>> On 5/8/19 8:49 AM, Aubrey Li wrote: > >>>>>>> Pawan ran an experiment setting up 2 VMs, with one VM doing a > >>>>>>> parallel kernel build and one VM doing sysbench, > >>>>>>> limiting both VMs to run on 16 cpu threads (8 physical cores), with > >>>>>>> 8 vcpu for each VM. > >>>>>>> Making the fix did improve kernel build time by 7%. > >>>>>> I'm gonna agree with the patch below, but just wonder if the testing > >>>>>> result is consistent, > >>>>>> as I didn't see any improvement in my testing environment. > >>>>>> > >>>>>> IIUC, from the code behavior, especially for 2 VMs case(only 2 > >>>>>> different cookies), the > >>>>>> per-rq rb tree unlikely has nodes with different cookies, that is, all > >>>>>> the nodes on this > >>>>>> tree should have the same cookie, so: > >>>>>> - if the parameter cookie is equal to the rb tree cookie, we meet a > >>>>>> match and go the > >>>>>> third branch > >>>>>> - else, no matter we go left or right, we can't find a match, and > >>>>>> we'll return idle thread > >>>>>> finally. > >>>>>> > >>>>>> Please correct me if I was wrong. > >>>>>> > >>>>>> Thanks, > >>>>>> -Aubrey > >>>>> This is searching in the per core rb tree (rq->core_tree) which can have > >>>>> 2 different cookies. But having said that, even I didn't see any > >>>>> improvement with the patch for my DB test case. But logically it is > >>>>> correct. > >>>>> > >>>> Ah, my bad. It is per rq. But still can have 2 different cookies. Not sure > >>>> why you think it is unlikely? > >>> Yeah, I meant 2 different cookies on the system, but unlikely 2 > >>> different cookies > >>> on one same rq. > >>> > >>> If I read the source correctly, for the sched_core_balance path, when try to > >>> steal cookie from another CPU, sched_core_find() uses dst's cookie to search > >>> if there is a cookie match in src's rq, and sched_core_find() returns idle or > >>> matched task, and later put this matched task onto dst's rq (activate_task() in > >>> sched_core_find()). At this moment, the nodes on the rq's rb tree should have > >>> same cookies. > >>> > >>> Thanks, > >>> -Aubrey > >> Yes, but sched_core_find is also called from pick_task to find a local > >> matching task. > > Can a local searching introduce a different cookies? Where is it from? > No. I meant the local search uses the same binary search of sched_core_find > so it has to be correct. > > > >> The enqueue side logic of the scheduler is unchanged with > >> core scheduling, > > But only the task with cookies is placed onto this rb tree? > > > >> so it is possible tasks with different cookies are > >> enqueued on the same rq. So while searching for a matching task locally > >> doing it correctly should matter. > > May I know how exactly? > select_task_rq_* seems to be unchanged. So the search logic to find a cpu > to enqueue when a task becomes runnable is same as before and doesn't do > any kind of cookie matching. Okay, that's true in task wakeup path, and also load_balance seems to pull task without checking cookie too. But my system is not over loaded when I tested this patch, so there is none or only one task in rq and on the rq's rb tree, so this patch does not make a difference. The question is, should we do cookie checking for task selecting CPU and load balance CPU pulling task? Thanks, -Aubrey