Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1832187ybh; Thu, 23 Jul 2020 20:04:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCZIyyjH0CkY+31hHlwsKsm6qC9ULQQocZYULN0ZBgghShtwIYqQ0W2ftx9WYsaqafo3T7 X-Received: by 2002:a17:906:cecf:: with SMTP id si15mr7140724ejb.508.1595559859106; Thu, 23 Jul 2020 20:04:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595559859; cv=none; d=google.com; s=arc-20160816; b=Jp/b+YUY0EeAqzsHdgnni3J5yFUzWHSVqMMXrL8d+PHLHCis8wVSyJS1nAbQ5I2QOY VNSyGiY9y0mCSUgENiDtiMpsODTZ5zLg8nOfV3p41Xm/KgZTKmqX55ERkdrt738YgeyW y5r01nFOdd7r6zC1v6FTtYPnPguTA+paeeDvzSF2rbfSALgQFHExKnM7Dybb2+1wAZPm 3sMwIbdzIjI3Hv9RGJypktjtMmnKBs1NpB2+8FUlsZSmEPgIsn/Q9DnUaFyAgEM6UdUa 69X4ysVpmjZldHtCJt9lBtCKZry6H70Dh/1UG/dNotgANCngWFtTfv11QPYzX/SG33IT OWVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :dkim-signature; bh=xnkanCRIM062ProhdGg7SX02oIMnz/wnozev/bBtcZI=; b=06CQBbYFe4uY3ilxPLcj6BQGk7xy6kKXLi3Sjc1VnZVGNAR18EbwKtXL1zxw7ufvB7 2fzsfQVwz1SB10vZXeMfuqej/6qlYSAWKar+4l1kl9yhAjaKe5KG+IYSbhzFTz+ml6y1 3jycpUnVHo6p1uuLkz4AUGt1AhUJIZZwonHM0NrzMWp0LmhQg0qO47xBzxTgJ6Zl20Zj SHZD2l5//4nJ2UQNUuoPurylxFBoZG7L4nzAkyAYPH+Jxxz+SEbB1Pzy8Ka3aYC3jM7Q gOLeGTho7W9CUuUqk7fx+dvjiTNSHrNNQTsWqQ7uYAbfqX0iNmL+g4nlYdFAX1+9fMzQ a08Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QQsGRhL6; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a24si2943739ejs.633.2020.07.23.20.03.56; Thu, 23 Jul 2020 20:04:19 -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=@redhat.com header.s=mimecast20190719 header.b=QQsGRhL6; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726747AbgGXDBB (ORCPT + 99 others); Thu, 23 Jul 2020 23:01:01 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:41939 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726178AbgGXDBA (ORCPT ); Thu, 23 Jul 2020 23:01:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595559658; 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=xnkanCRIM062ProhdGg7SX02oIMnz/wnozev/bBtcZI=; b=QQsGRhL6qOwc788PDSWIyPc+Lgj+skSVn1mWocRe6NsemJnYY9KGSWPnRUwrevNxbDmKsl LDdgo+USkGD0AUZZ8Jv/cb1ctk4t5524f71EDKct1Ds0Ke/eUURNZlzdADUv2p5QZb25UH 6lUFxA7j2ZPorugSko+Wt1eEwk7F1m0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-124-dPBfuT8yPHSvcsSJBoqEXw-1; Thu, 23 Jul 2020 23:00:54 -0400 X-MC-Unique: dPBfuT8yPHSvcsSJBoqEXw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4707257; Fri, 24 Jul 2020 03:00:52 +0000 (UTC) Received: from llong.remote.csb (ovpn-119-128.rdu2.redhat.com [10.10.119.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83F775D9D3; Fri, 24 Jul 2020 03:00:50 +0000 (UTC) Subject: Re: [PATCH for 5.9 1/3] futex: introduce FUTEX_SWAP operation To: Peter Oskolkov , Peter Zijlstra Cc: Linux Kernel Mailing List , Thomas Gleixner , Ingo Molnar , Ingo Molnar , Darren Hart , Vincent Guittot , Peter Oskolkov , Andrei Vagin , Paul Turner , Ben Segall , Aaron Lu References: <20200722234538.166697-1-posk@posk.io> <20200722234538.166697-2-posk@posk.io> <20200723112757.GN5523@worktop.programming.kicks-ass.net> From: Waiman Long Organization: Red Hat Message-ID: <00ec99e0-2164-123e-44ed-229c52119d7e@redhat.com> Date: Thu, 23 Jul 2020 23:00:50 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > >> 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. Cheers, Longman