From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-io1-f50.google.com (mail-io1-f50.google.com [209.85.166.50]) (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 408AD14A095 for ; Wed, 15 Jan 2025 15:23:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736954624; cv=none; b=gFjQtMbsQ0TxDKdlzfZJM/b9XSyP7hfsJXp8Mnu3xVsBCFHxbMs3jvW46e4nEbEOrdlpMGi//SqXNk/6f8pQB0OphiG9H02wdMkpGUH2P+Jej2Q6riXMDFEUsIYvclP4BAu+V+p640KHmXQZosIHJeyY9+IClNyMkZZ/bHsR+SA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736954624; c=relaxed/simple; bh=FpbWNghr4I3oH1ZpXlgglf4cIPZC7j3EO3dFtNeqQ3k=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=E3HvCM/AqJKaytJTdtxkZ7beVidTbVSL1fA9jtANSKK0Y44ayRYXdifdYEcffxaJ9D0jzrBoqCp+wtW3ArGS2FOhbE8BZywg+YoXsOtaaSH47cq5cNEi4oTsVoA3mjSNLVKRwh4KqT0ypLZclYh/jEas0gMdUdkx70kD2Ph1WoI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk; spf=pass smtp.mailfrom=kernel.dk; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b=DZFib0oX; arc=none smtp.client-ip=209.85.166.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kernel.dk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b="DZFib0oX" Received: by mail-io1-f50.google.com with SMTP id ca18e2360f4ac-844e39439abso220049639f.1 for ; Wed, 15 Jan 2025 07:23:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1736954621; x=1737559421; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=SQITDuwTLGqqA/jrunc3wxHx18rrm4NsNZTAokS06qs=; b=DZFib0oXM+aoqHOlScMFg27pgZW93ZCtSMCs44AFxdiAIDtAWp+cIiNzAX9WNWy18i wo3Jc2Uti81xo9hHHiwPBrNDNVI1y1VBe33XTE953/MRT3f1tEnpMHQU38Du8BBsZylm AVytpX0jUW5VwdR4tMK1sL4KltCn5OguDgifJkz7Lr+o5aTHTvRBX2ddljdgxL/RnN0W +Il08kxwEtcMi7cQbmIFAxJnhknSO8zNCl66FbySLkLZwOR/k/2OsWBaDiWRqFMRJV4j jCVjh+zQYP7e9PVPFLVonQrEFxaAI++VeK6bC7kc7+GC1qEJDJWGV9rP3UBit+w1GKvc yVlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736954621; x=1737559421; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SQITDuwTLGqqA/jrunc3wxHx18rrm4NsNZTAokS06qs=; b=MjDIbxeQtV7xuBut4/Hcp2sil5fq7nsPY0THhSyrqHPvCcWkZmZfHJ02mo47yWC73w aszTcfU/zvmcDH/HnYkYKs9NW6UCS5XBj22dWqNl5fmQIsjFW4MtY3qilnROj5yDQYB5 aSuimN+CuhMscN1CKXD/jDtduwysyHAgVWz7npsiI42KSc1DV7LUNxTHaAy+sGjaazA/ 7bSIv6+yWGrhFrG9O3x13IIrj3QDEzwZIWkU7JG0gDh3TeuSzv7987UQBI2Wcu/PS2iI 7F5M9D86tx96SgP3aGRXvqHGsGz3HRxIZO0+StMrEqy/JnMp58y1jOgDEarOBlqlyEIX fenw== X-Forwarded-Encrypted: i=1; AJvYcCXEsKNSJiwSBsE/crn7a/tLfUYYe3U33VOfD7XdpkBMrT6Hh2hMLggZg3CPx2ie6OEpZwagwr6FR7odhso=@vger.kernel.org X-Gm-Message-State: AOJu0Yz8faLm1DisuLaPWpQ8n2YUIyMvZmWAMPSOP7mTBicOPGB+RNFt K3oPabumCEYeFc2ROHv8i4eSgoeltCxp3erArI4uMeubhwTfR+qBi2VU6Vg7/kU= X-Gm-Gg: ASbGnct6CaYr/1ibVgeEA1HlexYp+aiKoA7kGiYqk7I3vfyZCagFMhbVDNyMRBF7/31 d9VrZ984gYDWsczPI8qlxK7e8lzx/qNBqXUROiQs1uwTbcX2WFBJTCSs1HccQbe8wICHyYoAMes lT6PBdAgF28eN5Ydn3TNykuKNuL9cWoZhsNfJ+Qo4b4GaR+spLLD/OsCSYnX6j8nELCtj3Y9i+D LEDQwCn3nR3ZBws3XeGwkvNr/FH9uEKpi02I0H432vRdVj+btpp X-Google-Smtp-Source: AGHT+IEwpf/Y1pi5fFJxzWkZxnCJSCrhdfX2xFxZLqXFx82QSyDTzJQYxD36oOloRcH8GeHEpriO8w== X-Received: by 2002:a05:6e02:13ad:b0:3ce:8ed9:ca81 with SMTP id e9e14a558f8ab-3ce8ed9ce12mr8462085ab.5.1736954621276; Wed, 15 Jan 2025 07:23:41 -0800 (PST) Received: from [192.168.1.116] ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3ce8b096ecbsm2512055ab.36.2025.01.15.07.23.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Jan 2025 07:23:40 -0800 (PST) Message-ID: <30a6d768-b1b8-4adf-8ff0-9f54edde9605@kernel.dk> Date: Wed, 15 Jan 2025 08:23:39 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: futex+io_uring: futex_q::task can maybe be dangling (but is not actually accessed, so it's fine) To: Thomas Gleixner , Peter Zijlstra Cc: Jann Horn , Ingo Molnar , Darren Hart , Davidlohr Bueso , =?UTF-8?Q?Andr=C3=A9_Almeida?= , kernel list , Pavel Begunkov , io-uring References: <3b78348b-a804-4072-b088-9519353edb10@kernel.dk> <20250113143832.GH5388@noisy.programming.kicks-ass.net> <877c6wcra6.ffs@tglx> Content-Language: en-US From: Jens Axboe In-Reply-To: <877c6wcra6.ffs@tglx> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 1/15/25 3:20 AM, Thomas Gleixner wrote: > On Mon, Jan 13 2025 at 15:38, Peter Zijlstra wrote: >> On Fri, Jan 10, 2025 at 08:33:34PM -0700, Jens Axboe wrote: >> >>> @@ -548,7 +549,7 @@ void __futex_queue(struct futex_q *q, struct futex_hash_bucket *hb) >>> >>> plist_node_init(&q->list, prio); >>> plist_add(&q->list, &hb->chain); >>> - q->task = current; >>> + q->task = task; >>> } >>> >>> /** >> >> The alternative is, I suppose, to move the q->task assignment out to >> these two callsites instead. Thomas, any opinions? > > That's fine as long as hb->lock is held, but the explicit argument makes > all of this simpler to understand. > > Though I'm not really a fan of this part: > >> + __futex_queue(&ifd->q, hb, NULL); >> + spin_unlock(&hb->lock); > > Can we please add that @task argument to futex_queue() and keep the > internals in the futex code instead of pulling more stuff into io_uring? Sure, was trying to keep the change more minimal, but we can certainly add it to futex_queue() instead rather than needing to work around it on the io_uring side. I'll be happy to send out a patch for that. -- Jens Axboe