Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp739203imn; Thu, 28 Jul 2022 14:21:37 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vnRIL7hjCdKhSr5Av1yo5ujtfcoIrDki4g3HRmCULMK2rKU1XALtQBseFTbVhFtfcfnGUn X-Received: by 2002:a05:6402:4504:b0:43b:4ec7:2ec1 with SMTP id ez4-20020a056402450400b0043b4ec72ec1mr792224edb.7.1659043297107; Thu, 28 Jul 2022 14:21:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659043297; cv=none; d=google.com; s=arc-20160816; b=Vl2DXRTL3g5TuTzGOobg2rx69ThzymWbPGXf0apBWFcFTFOOgXsvNxtnd8Bery6hjP lyAF8OSJBVChUb5H6FraZX1SOttWl7Mri2k/dXALD5qKhTOD7Ic1jdjiJUKk50J1Mvg0 38AJElORhj88aeSxoeCQUwQwh7Et+9NVcUnHpyUt8KTb96XPlWVF8Um8L4A7weMzQRg6 VBv9OPJ3sEf4y4QG86mlJuwbB2axes8TagOjljhXnGxMvGaRbTX1oys9f2a5ydneLnzd MKa2ycV1E+eS/Wrwr+uS0bNUKzPxZuqKVjA+FkInEoVJJPl7cnmSuPaDezksLwE7gHU8 qENQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=PRBCCH+EkIgUpXOLdlJYEsIwuOxdedTFnF9t4CuFePQ=; b=f2IQPJdGH1J/cTSy/gQJhHQgyqFNCt96CY8BT3HV74zR8P/M+f8SsD4877G5X41oUv gD+gPfH81gWdJrqoOPNtXesFuC9QxYV/rXdWbm/fpaWaUNbRU9bCZ0d0w4cwdh79ZV99 vURYEmdus98Lo0fi1hp3WlI14+iDFpx5lkx5FIOQfhokGhnK1rwhBO3InnVWJ4sLowAh +54MgvF7GE1FGjm9DFoLyv8Nox4FpppIbvT1dAT1liQLetNTgEN8SWYM3wQNXxgiM4Nh tPO78Ro/LCb/8eCbWrfE5/yJ+CQ/B28nLx7I1jgOnGZ4rQqM1BqqNikOZv/znqC6zEvz Zuww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GfJP0q1d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x19-20020a1709064bd300b0072b9b9c2a74si128414ejv.251.2022.07.28.14.21.12; Thu, 28 Jul 2022 14:21:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GfJP0q1d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232113AbiG1VE1 (ORCPT + 99 others); Thu, 28 Jul 2022 17:04:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229735AbiG1VEZ (ORCPT ); Thu, 28 Jul 2022 17:04:25 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E24233A9 for ; Thu, 28 Jul 2022 14:04:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659042264; 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=PRBCCH+EkIgUpXOLdlJYEsIwuOxdedTFnF9t4CuFePQ=; b=GfJP0q1dnCjsYDHjhnofuklOFFJJrNIWqpfIt7XNEkJjbc83xPmgHzrFaczVmprwHQvIFx isQb2DgCIOBjA56V+nuhZZkyDklOCJJxOTFPvMJL106TuSdmeL6JmLuvzKzCMTeGIF7QjU RNyYtC8SDZFtD/nuzc8ieBSk8UJi02o= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-668-hc4-0P1tNrmW5ouNv8cVHw-1; Thu, 28 Jul 2022 17:04:22 -0400 X-MC-Unique: hc4-0P1tNrmW5ouNv8cVHw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BA6EE280303F; Thu, 28 Jul 2022 21:04:21 +0000 (UTC) Received: from [10.22.9.86] (unknown [10.22.9.86]) by smtp.corp.redhat.com (Postfix) with ESMTP id C582D140EBE3; Thu, 28 Jul 2022 21:04:19 +0000 (UTC) Message-ID: Date: Thu, 28 Jul 2022 17:04:19 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH 1/2] cgroup/cpuset: Keep current cpus list if cpus affinity was explicitly set Content-Language: en-US To: Tejun Heo Cc: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Zefan Li , Johannes Weiner , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220728005815.1715522-1-longman@redhat.com> <1ae1cc6c-dca9-4958-6b22-24a5777c5e8d@redhat.com> <606ed69e-8ad0-45d5-9de7-48739df7f48d@redhat.com> From: Waiman Long In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/28/22 16:44, Tejun Heo wrote: > Hello, > > On Thu, Jul 28, 2022 at 03:21:26PM -0400, Waiman Long wrote: >> On 7/28/22 15:02, Tejun Heo wrote: >>> On Thu, Jul 28, 2022 at 02:57:28PM -0400, Waiman Long wrote: >>>> There can be a counter argument that if a user found out that there is not >>>> enough cpus in a cpuset to meet its performance target, one can always >>>> increase the number of cpus in the cpuset. Generalizing this behavior to all >>>> the tasks irrespective if they have explicitly set cpus affinity before will >>>> disallow this use case. >>> This is nasty. >> That is a nasty example, I know. There may be users depending on the >> existing behavior even if they don't know it. So I am a bit hesitant to >> change the default behavior like that. On the other hand, tasks that have >> explicitly set its cpu affinity certainly don't want to have unexpected >> change to that. > Yeah, I hear you. I'm on the same page. > >>> The real solution here is separating out what user requested >>> and the mask that cpuset (or cpu hotplug) needs to apply on top. ie. >>> remember what the user requested in a separate cpumask and compute the >>> intersection into p->cpus_maks whenever something changes and apply >>> fallbacks on that final mask. Multiple parties updating the same variable is >>> never gonna lead to anything consistent and we're patching up for whatever >>> the immediate use case seems to need at the moment. That said, I'm not >>> necessarily against patching it up but if you're interested in delving into >>> it deeper, that'd be great. >> I believe the current code is already restricting what cpu affinity that a >> user can request by limiting to those allowed by the current cpuset. Hotplug >> is another issue that may need to be addressed. I will update my patch to >> make it handle hotplug in a more graceful way. > af > So, the patch you proposed is making the code remember one special aspect of > user requested configuration - whether it configured it or not, and trying > to preserve that particular state as cpuset state changes. It addresses the > immediate problem but it is a very partial approach. Let's say a task wanna > be affined to one logical thread of each core and set its mask to 0x5555. > Now, let's say cpuset got enabled and enforced 0xff and affined the task to > 0xff. After a while, the cgroup got more cpus allocated and its cpuset now > has 0xfff. Ideally, what should happen is the task now having the effective > mask of 0x555. In practice, tho, it either would get 0xf55 or 0x55 depending > on which way we decide to misbehave. OK, I see what you want to accomplish. To fully address this issue, we will need to have a new cpumask variable in the the task structure which will be allocated if sched_setaffinity() is ever called. I can rework my patch to use this approach. Thanks, Longman