Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp415618rdb; Thu, 21 Dec 2023 13:02:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IG62TBUv/2mrwmTg/Dec9lP2TZ1fkduOD04lMJeYNE0avWN7WfvRaX+XBtHc5I2/iZBUB2X X-Received: by 2002:a17:90a:de94:b0:286:9b25:1c66 with SMTP id n20-20020a17090ade9400b002869b251c66mr387130pjv.24.1703192553699; Thu, 21 Dec 2023 13:02:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703192553; cv=none; d=google.com; s=arc-20160816; b=GDMBLtp70zFHOd3V1js4IjagRiPp6f6v99kHKix6j69qQJMMSVGE1It13gItP8n4TL oUWYqfA0+t180nPU2MujMGL3tuG513V8MwDa+Mz+IDggE27M7Pu+XozN2nuxLqLFFRp4 YSG8f+SDzldC2PVwWS7NVUI9sw0bgOchRPIQ+ch2tpqnUoVyP6OrIlJmpKPT5/L9XsVX VGZwXvF4/zTcbW+xqyCiJOcbz9T8wFR04hKdYALz+7onGg/2BNJ7JLHtoY1K9QbnzmRl CtGvFbGQjarhoTCn45anq4mkN2SZ+xbi+QcloWKS0oVA0knP3pvsMh4sF9xs1Mh7WA5h IO9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=7mWkghfYP9nF3cpCu7P/2tNGjkl1FoH8YSgSyUvHGBU=; fh=sfPBq54ML2fG8A22Al9QQuvYCS4br8yO/w/6miWC03M=; b=O6HI6cjNtbsa1N+5R26W9iHy3R2/rj4qDq3aU05c1lcWtHkRbDqLKkcqRJm9kECXcd xefDFDQuoRiAdMSQZwrmiR2nq/G5QB52voZ76jMQdzkKYkbkWdd6myATz8l5VQY4+ktN cRu+Hb99BowMpbDISEpJq66vXNzDielJbYBqLaQNnzO0uf6oWvCQQ4xlN8Hbj4ZlywAH 5DfZHiBk2r1NE2dPNtRt3usgL+eoMMXX56HXZ6asQ2a5/Sm0tWBQ57T9phtMJ6piXh1Z wqoHbmYlFJPcgk6R7b96fkYgRPrL+et3cP+htHvueje6mgE4GPEOO9u35uqoY209tBjA CQ/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=v3UMJUT4; spf=pass (google.com: domain of linux-kernel+bounces-9069-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9069-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id t3-20020a17090abc4300b0028b8e72defesi2161014pjv.21.2023.12.21.13.02.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 13:02:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9069-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=v3UMJUT4; spf=pass (google.com: domain of linux-kernel+bounces-9069-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9069-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 9CC86B23915 for ; Thu, 21 Dec 2023 21:02:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 12B9F76DA2; Thu, 21 Dec 2023 21:02:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="v3UMJUT4" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ABCE96280F for ; Thu, 21 Dec 2023 21:02:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-40d41a32effso17195e9.0 for ; Thu, 21 Dec 2023 13:02:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1703192539; x=1703797339; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=7mWkghfYP9nF3cpCu7P/2tNGjkl1FoH8YSgSyUvHGBU=; b=v3UMJUT4NV2Cxq2L8UFTKk46RDY6IkvP35YTp973/XcJUwPgURtqmTR+AouImRRpdX 4leQlIZXjhrwDEQ5k/SwTKdP6FMswaoX4GFBxlvo+fg2fH51hrBAbo4huhheB/yRm7rY EDjwuCzh1sN7AN7iN3uXSI647YMNg+dyhiSHrLKbiZ5AkgSK7RkdRax1PacKu96CqkXN 1uW0QboRcfJuxijry6LShKyi77HMJDmv6ojsgtmp7SheVTv7t8ypAYG/lconP5sFXXDt l0lM9AXVpnvPnuF/V0qQYCPXhBY4ywuhV058dDqmFswPRqPoVj8+7O+VTJU45uPi1rLH ga7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703192539; x=1703797339; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7mWkghfYP9nF3cpCu7P/2tNGjkl1FoH8YSgSyUvHGBU=; b=d87THAj9ej6xKyuWGdk2omF9zpsP8+6T3oY9hL/yeGSI93XfX42Wo6GkOA6oKJfpGc wyhI72rgmNpNsmOEyfD6mIexPq5zr+msjwn17Cr98P3P5PkrnENdXgeCRsRcZMsi305o +q+FskIXTSVRTbxmjBnuH9FMyqgoAPhRNxLLNgU1qoJQIKljD77gSZnTqTroowUfsGEo GVFkqMNXOX61Dp4hHQEQfItJPvC2qG0zdWFmwfZ9WpAufFnLgI8jJC6p/a2Du5BcJiWR nxQatZRctJVHbsUBXERr9NKDtgcIxroQihogA/UXcEWQQ9R8ssOwynseXIjVm8+p33Wh 7IJw== X-Gm-Message-State: AOJu0Yx3snBj7pvqSGo7A0P0APphfWfsYCHSj7qsAdJQPAoIbSNxWIGR ztxUjNM4qQwi2b4T6NopgVI6UW/j3YmU702QZ/tW+Od1/ZM= X-Received: by 2002:a05:600c:63c3:b0:40d:1bcf:1abf with SMTP id dx3-20020a05600c63c300b0040d1bcf1abfmr25376wmb.6.1703192538700; Thu, 21 Dec 2023 13:02:18 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231220001856.3710363-1-jstultz@google.com> <20231220001856.3710363-13-jstultz@google.com> In-Reply-To: From: John Stultz Date: Thu, 21 Dec 2023 13:02:05 -0800 Message-ID: Subject: Re: [PATCH v7 12/23] sched: Fix proxy/current (push,pull)ability To: Metin Kaya Cc: LKML , Valentin Schneider , Joel Fernandes , Qais Yousef , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Valentin Schneider , Steven Rostedt , Ben Segall , Zimuzo Ezeozue , Youssef Esmat , Mel Gorman , Daniel Bristot de Oliveira , Will Deacon , Waiman Long , Boqun Feng , "Paul E. McKenney" , Xuewen Yan , K Prateek Nayak , Thomas Gleixner , kernel-team@android.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Dec 21, 2023 at 7:03=E2=80=AFAM Metin Kaya wro= te: > On 20/12/2023 12:18 am, John Stultz wrote: > > +static inline void proxy_tag_curr(struct rq *rq, struct task_struct *n= ext) > > +{ > > + if (sched_proxy_exec()) { > > Should we immediately return in !sched_proxy_exec() case to save one > level of indentation? Sure. > > + /* > > + * pick_next_task() calls set_next_task() on the selected= task > > + * at some point, which ensures it is not push/pullable. > > + * However, the selected task *and* the ,mutex owner form= an > > Super-nit: , before mutex should be dropped. > > > + * atomic pair wrt push/pull. > > + * > > + * Make sure owner is not pushable. Unfortunately we can = only > > + * deal with that by means of a dequeue/enqueue cycle. :-= / > > + */ > > + dequeue_task(rq, next, DEQUEUE_NOCLOCK | DEQUEUE_SAVE); > > + enqueue_task(rq, next, ENQUEUE_NOCLOCK | ENQUEUE_RESTORE)= ; > > + } > > +} > > + > > /* > > * __schedule() is the main scheduler function. > > * > > @@ -6796,6 +6813,10 @@ static void __sched notrace __schedule(unsigned = int sched_mode) > > * changes to task_struct made by pick_next_task(). > > */ > > RCU_INIT_POINTER(rq->curr, next); > > + > > + if (!task_current_selected(rq, next)) > > + proxy_tag_curr(rq, next); > > + > > /* > > * The membarrier system call requires each architecture > > * to have a full memory barrier after updating > > @@ -6820,6 +6841,10 @@ static void __sched notrace __schedule(unsigned = int sched_mode) > > /* Also unlocks the rq: */ > > rq =3D context_switch(rq, prev, next, &rf); > > } else { > > + /* In case next was already curr but just got blocked_don= or*/ > > Super-nit: please keep a space before */. Fixed up. Thanks for continuing to provide so much detailed feedback! -john