Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1842474ybh; Thu, 23 Jul 2020 20:24:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrXKQJh5LzWdgqUMco2o1uQgClaUjTFOxd8OEs0x//EaOT2RmAVgqPOPRo0obmc8DzFJta X-Received: by 2002:a17:906:b217:: with SMTP id p23mr7590550ejz.98.1595561076745; Thu, 23 Jul 2020 20:24:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595561076; cv=none; d=google.com; s=arc-20160816; b=erHVX+OuYxGjXSqd86vFSBGEOIRZ6wzhfMNT9HckA6CCozUAwNj6GU/DVI3Ai69ner 3Q4KrEBz7ZdxeXkdznpQ2FBtpXobzpV4iq2WLlgbSPiautpqyG+1ivOSik1EeZQTRgeF 3XDju8GwsjYbDD810m1mb773ArCRcMUJQxhQbTj/BDEu/eQ/UGSj4BRiamEakcDwZt5B +lyytQc1v1WwHzro15KfeI770dTAUx9HyrZMuOqZzqEliQSKyJ4wrgcuyEY28SbzMS1U fsRbhc/Px/J4SUtBJdm3fl6r2oSP4Hg5Q9fuqwm+pjDpWhq17EH/9citez9viS03MvBE uZbA== 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=uvFWn/1JCosuktFTpXt71BPZd5GcGPpKpGz+xAWCarU=; b=scPLLi8X8wg71ychEc33B3eE08zTEi9YF/Dl3APLGaavtqDzyKJMfOuzNU0qs1wcgU UP9TbKiZoY5Zy7NBeUmmVeFHnGmWFsHfBc2dcaQqczNDXUMFWiQcmE4+1byqG+62xfQo Y1y9PL7nx/62uApsUQUNanUCrtCsNGGxzMZTJjdtZzDE9DtpuvjKTmQyUQJVnfIpZrAs L0Vbnhc4z5eUvwUvU4AuZNyKeNnoAOKAl618zrhvY0MoaF+NO5Uay/8JjvJHlYGX6uv1 sESlDp/hNCKO5M/Gwxn2C3nMJc40SJxxIT1XClkmKYRxR7WFnWZbKXUilURbQBGo8jZE q08A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@posk.io header.s=google header.b="LGBa/mwC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c26si3156294edy.599.2020.07.23.20.24.13; Thu, 23 Jul 2020 20:24:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@posk.io header.s=google header.b="LGBa/mwC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726692AbgGXDW0 (ORCPT + 99 others); Thu, 23 Jul 2020 23:22:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726425AbgGXDW0 (ORCPT ); Thu, 23 Jul 2020 23:22:26 -0400 Received: from mail-ua1-x942.google.com (mail-ua1-x942.google.com [IPv6:2607:f8b0:4864:20::942]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD874C0619D3 for ; Thu, 23 Jul 2020 20:22:25 -0700 (PDT) Received: by mail-ua1-x942.google.com with SMTP id b24so2522306uak.2 for ; Thu, 23 Jul 2020 20:22:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=posk.io; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=uvFWn/1JCosuktFTpXt71BPZd5GcGPpKpGz+xAWCarU=; b=LGBa/mwCnw7hgzeMQ1yOE4W3LBvHtBnCXxv2as5aZkYuE4RqRV/vLj2uJX63HFs0F/ fa7muY3QhSIGQTSC36CVRF6GjJ0agjGwzbpUn1HdI0gvJyUW/elwi7I6C4V6bQow5xd4 gVcXd+fDhD4cDECAxsJNiZ40XCWrQTQItFdL4EW+g9U/0o2O39bUGosRsNlCZOgk3EQo iAeLxxyeaXtgF48MZZsLSJONGHTC87K4eH+sa3OO0tpR700GXnHuxB74kfyQDGZxJe9h k2pmP/tpabqutJiE1vfraNfy6a9xFQIcuS+ZtNaBVahrMedLufCQ2HqscQOogJcRWfWP xqAw== 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=uvFWn/1JCosuktFTpXt71BPZd5GcGPpKpGz+xAWCarU=; b=hKCbJPiZTnG3glWmcbq0hxCc+WbQWCPufz5u2ehKJBoi+rWf8eSP76006vKw9zPoiX /o4ToV5DUhFSJM4ZXZd0/Hqyz2z7MWdB+F0lRzR7LYCJtqoEItQPEfOhi64rN1twweP4 w7gVzoYjdlb//idsQkJn+UveNkiOa7HfEpPMRHmVAZSvgsXybp1dZZr2S1xKMqtMEIG5 7CgXQgJxBxkDy3NpjkECexpFm13B4KFlYGNG3/rwyFimM0kHLvbHAOFSZ0C73Teo+sSx dUxRjz967lq735OVbDq1uClr6vppBRnTdI9b01lv9OATwlnwLbIGuLojUpCOPdXD0t6j hW4g== X-Gm-Message-State: AOAM532izQ+/Y3PeupPN8kQ5B7MdiYWejO7cwglBpQgimst6pa79bIPk Dxe8V9YO8lFXkDqQDB/rsIaES9zsgk1N2cYUT6m3kg== X-Received: by 2002:ab0:22cf:: with SMTP id z15mr6706030uam.52.1595560944996; Thu, 23 Jul 2020 20:22:24 -0700 (PDT) MIME-Version: 1.0 References: <20200722234538.166697-1-posk@posk.io> <20200722234538.166697-2-posk@posk.io> <20200723112757.GN5523@worktop.programming.kicks-ass.net> <00ec99e0-2164-123e-44ed-229c52119d7e@redhat.com> In-Reply-To: <00ec99e0-2164-123e-44ed-229c52119d7e@redhat.com> From: Peter Oskolkov Date: Thu, 23 Jul 2020 20:22:14 -0700 Message-ID: Subject: Re: [PATCH for 5.9 1/3] futex: introduce FUTEX_SWAP operation To: Waiman Long Cc: Peter Zijlstra , Linux Kernel Mailing List , Thomas Gleixner , Ingo Molnar , Ingo Molnar , Darren Hart , Vincent Guittot , Peter Oskolkov , Andrei Vagin , Paul Turner , Ben Segall , Aaron Lu 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, Jul 23, 2020 at 8:00 PM Waiman Long wrote: > > On 7/23/20 8:25 PM, Peter Oskolkov wrote: > > On Thu, Jul 23, 2020 at 4:28 AM Peter Zijlstra wrote: > > > > Thanks a lot for your comments, Peter! My answers below. > > > >> On Wed, Jul 22, 2020 at 04:45:36PM -0700, Peter Oskolkov wrote: > >>> This patchset is the first step to open-source this work. As explained > >>> in the linked pdf and video, SwitchTo API has three core operations: wait, > >>> resume, and swap (=switch). So this patchset adds a FUTEX_SWAP operation > >>> that, in addition to FUTEX_WAIT and FUTEX_WAKE, will provide a foundation > >>> on top of which user-space threading libraries can be built. > >> The PDF and video can go pound sand; you get to fully explain things > >> here. > > Will do. Should I expand the cover letter or the commit message? (I'll probably > > split the first patch into two in the latter case). > > You should put it mostly in the commit message which will be part of the > git log history. The cover letter, on the other hand, is not part of the > git log. Ack. (Networking/David Miller usually includes the cover letter in the git log, so this is context dependent, I guess). > > > > > >> What worries me is how FUTEX_SWAP would interact with the future > >> FUTEX_LOCK / FUTEX_UNLOCK. When we implement pthread_mutex with those, > >> there's very few WAIT/WAKE left. > > [+cc Waiman Long] > > > > I've looked through the latest FUTEX_LOCK patchset I could find ( > > https://lore.kernel.org/patchwork/cover/772643/ and related), and it seems > > that FUTEX_SWAP and FUTEX_LOCK/FUTEX_UNLOCK patchsets > > address the same issue (slow wakeups) but for different use cases: > > > > FUTEX_LOCK/FUTEX_UNLOCK uses spinning and lock stealing to > > improve futex wake/wait performance in high contention situations; > > FUTEX_SWAP is designed to be used for fast context switching with > > _no_ contention by design: the waker that is going to sleep, and the wakee > > are using different futexes; the userspace will have a futex per thread/task, > > and when needed the thread/task will either simply sleep on its futex, > > or context switch (=FUTEX_SWAP) into a different thread/task. > > I agree that it is a different use case. I just hope that you keep the > possible future extension to support FUTEX_LOCK/UNLOCK in mind so that > they won't conflict with each other. Ack. Will do. :) Thanks, Peter > > Cheers, > Longman >