Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2948288lqo; Tue, 21 May 2024 02:04:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUZgt9QPQBdBHlN1l3TsTZ0dPM0IY9P273rBYhDqeZ+xto4GmlBa3aZztQpwI2JH2S+dtAEub+w/pMH6EyL+t3kglWBE943K28PmgFreg== X-Google-Smtp-Source: AGHT+IFOWw1X/xbBNfKN6ifqrbgJLNZZfzSplNY/RKyFzXBijWiKie/H1CliSowCBgeQbq3h5m1f X-Received: by 2002:a05:620a:84f:b0:790:fd04:5a1b with SMTP id af79cd13be357-792c7574a7fmr3486055585a.9.1716282241963; Tue, 21 May 2024 02:04:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716282241; cv=pass; d=google.com; s=arc-20160816; b=ShIMD4Yj4nDIYPYy2mTD4p433kHkekKyR4nzSlvTvbxc2NOwqUGdIt76zDgQtVxOlz Qlxl1e+9vUKmprOELNvrF/8UV6ovEUxB0w7ZjT/7HWQH0ht17D9mzdye0hQPHa284DKW Y0xl2QLParJuD76tJ9b1qZukehWPFXQmFBLs2YDFlcNogl9vs5F5EilPdyozZOybetTx RgUKVriH54w/8AUPyyqrLhvjfEflsCuteRvitcIYldqHxG3WJ65uGq5hn40FkLKHzafB SHTJqNlqaZvqlDP9Y5cK6597YO/dEbw4YpR2NzcVAx9uwmra8eItbnpZHaqpmcnRYQHi 9h8Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=Bh7W8N7Kjlu+sUoloK6kktcE+ERzsp6+vlPGr92bmBc=; fh=A2KfJNGzCR2O5OP9Jc7mPAAdN/LYznuJcA+A/PoopmU=; b=r0Jdtt38+irS6uEmWirp+8ooDAOgZHH8fc5+VaK0jQDprTeo+PCsazJRKXlBmVwA+q UosR9Py0NhF84OIHEhwCvDWFGhIfkemixaAx/gWWDFzhPN8rpj0Ljcej1l7ShbZNkysk g2som6vpSGtOpB5OvobbX/sRbSjR4qgFXldit74hEkZQG+unIDmcRD0Sf7p/iouEv2V/ co4WB2MxhGbQxvI4G95XZ5dZKBKD9mZG9h7Jq+YRnb+Kt1ueLmLJbEDlpfMoGENzBfv4 KCG+AvvAkQQf5z9QZooNSRlk7kVjWjeWAd7opd+BGRHScpuVIA6Be3v83YXSiEL4i00f JWsg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="N/AnxtBw"; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-184678-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184678-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-792bf30a3besi625352285a.288.2024.05.21.02.04.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 02:04:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-184678-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="N/AnxtBw"; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-184678-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184678-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 8530D1C21AA8 for ; Tue, 21 May 2024 09:04:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 976FB57C85; Tue, 21 May 2024 09:03:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="N/AnxtBw" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C2241BF31 for ; Tue, 21 May 2024 09:03:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716282225; cv=none; b=pJ4cuRDlIIFPeShuIq1AvFNGqqFRbkh7JELgqDaZ44t/WgqA16qVGQ88XyUjnTBw69bt1CbQa/74iXfC5GkqySLVaM6jquC8q4R+sRTdttEW0mPfClkkKkzBM2meW0/GpOHrJMtMEiL3DiY3//JVmTJN0P9DYkpPoFeDy2bswiU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716282225; c=relaxed/simple; bh=WwubyTck14hSYWNd+EZHq+sIN0JioSBlvg43BrUZZ3Q=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=WqS7t9Oo6p12OutE2boYWJk/aTia3Rb1sCVTn+WM3bSiYnbGohSda2WYPWC+R1P9ZwDOXCcbeVdm3DZVlNiB4mdoallic7vtRtelaAXPhs3gacYhpyfzDxgrHzy9v3Fj3VQP0qXDaMOIqSxGu4OuCmUp9gYXTJg5CtdtbqjmDWs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=N/AnxtBw; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716282223; 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=Bh7W8N7Kjlu+sUoloK6kktcE+ERzsp6+vlPGr92bmBc=; b=N/AnxtBwSe9NXPfQNlj6KsmMMdCg6LsLqyO067buGSNQcn99rJfHGWpou+VLtocsUPC3kt j0JXklvf8dCWaphmDQlRRYSWSEObsNMl9b7PF2AczI0tqgdOKULXKanVqSQbftnpFbGm50 VMXdElzCNiQ8jJYn2z1N30wr/jL0+sM= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-157-flggU6naOaeznaJwlYCUJQ-1; Tue, 21 May 2024 05:03:41 -0400 X-MC-Unique: flggU6naOaeznaJwlYCUJQ-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a5a8f3bc8e0so430888366b.1 for ; Tue, 21 May 2024 02:03:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716282221; x=1716887021; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Bh7W8N7Kjlu+sUoloK6kktcE+ERzsp6+vlPGr92bmBc=; b=qnwAOxDbcAOraorU9Eabl0IeCZ5rsB9t78zAlCmZd5Lk6mZ5I7XPcaAmd+UHM4KRzT IhQ/gslB35J73NfC+xZxKl9LVFdiNhwP3FllcEo2oNZtMWZrJhKUOLYeEc1w/ceuLncJ nVkg91RdkZBhgtBcERv+h+L8BpM2mWJ+jS4XBAUHXeolJxZvi2lkDsGYbptcWZk4vYaS YJutxDZcPf63nQdHSpnIboY2dFs0HQ0wexfsk726gaeFYT5db0ythLeJPYT11PRYqXIF /Qs0oGzcug2s8OeRXY3v4mcL3z7NgNm49wRvA0u3mU5Q6Pp3NTH1oxE5RiBuoRJfK8Dh 2jCw== X-Forwarded-Encrypted: i=1; AJvYcCX8bx5OZ9uMeCihviZV47u4L+7xGG5eX8JSvEszXShIdLMRCzck9smTnZuZ8dC+3dRlDKoRUoek8PwyN7VvzbgdfBShi10wJHLXb86N X-Gm-Message-State: AOJu0YwxZk+jFW9JmqsnSWRGTp3Sadb49Dqvbb4sfGxd63jfB5MblhI+ Jw7mF58PBIMzG4kr05YAr/PVnhmC4p9C79p5gNGAYMrs15Da/7oDoV28Fg1R7bJi0huHw/nqsiS foZqJ0UdvH4/pJKPP7fsciWNnmDwiJuJIwH9yAibSpi+il081DzyiGHyePzgVzw== X-Received: by 2002:a17:906:97c8:b0:a5a:a2b6:ba8b with SMTP id a640c23a62f3a-a5aa2b6bf6fmr1116718566b.0.1716282220784; Tue, 21 May 2024 02:03:40 -0700 (PDT) X-Received: by 2002:a17:906:97c8:b0:a5a:a2b6:ba8b with SMTP id a640c23a62f3a-a5aa2b6bf6fmr1116716766b.0.1716282220404; Tue, 21 May 2024 02:03:40 -0700 (PDT) Received: from vschneid-thinkpadt14sgen2i.remote.csb (213-44-141-166.abo.bbox.fr. [213.44.141.166]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a51eea36dsm1334475466b.58.2024.05.21.02.03.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 02:03:39 -0700 (PDT) From: Valentin Schneider To: Eric Dumazet Cc: dccp@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, "David S. Miller" , Jakub Kicinski , Paolo Abeni , mleitner@redhat.com, David Ahern , Juri Lelli , Tomas Glozar , Sebastian Andrzej Siewior , Thomas Gleixner Subject: Re: [PATCH v5 0/2] tcp/dcpp: Un-pin tw_timer In-Reply-To: References: <20240415113436.3261042-1-vschneid@redhat.com> Date: Tue, 21 May 2024 11:03:38 +0200 Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, On 22/04/24 16:31, Valentin Schneider wrote: > Apologies for the delayed reply, I was away for most of last week; > > On 16/04/24 17:01, Eric Dumazet wrote: >> On Mon, Apr 15, 2024 at 4:33=E2=80=AFPM Valentin Schneider wrote: >>> >>> On 15/04/24 14:35, Eric Dumazet wrote: >>> > On Mon, Apr 15, 2024 at 1:34=E2=80=AFPM Valentin Schneider wrote: >>> >> v4 -> v5 >>> >> ++++++++ >>> >> >>> >> o Rebased against latest Linus' tree >>> >> o Converted tw_timer into a delayed work following Jakub's bug repor= t on v4 >>> >> http://lore.kernel.org/r/20240411100536.224fa1e7@kernel.org >>> > >>> > What was the issue again ? >>> > >>> > Please explain precisely why it was fundamentally tied to the use of >>> > timers (and this was not possible to fix the issue without >>> > adding work queues and more dependencies to TCP stack) >>> >>> In v4 I added the use of the ehash lock to serialize arming the timewait >>> timer vs destroying it (inet_twsk_schedule() vs inet_twsk_deschedule_pu= t()). >>> >>> Unfortunately, holding a lock both in a timer callback and in the conte= xt >>> in which it is destroyed is invalid. AIUI the issue is as follows: >>> >>> CPUx CPUy >>> spin_lock(foo); >>> >>> call_timer_fn() >>> spin_lock(foo) // blocks >>> timer_shutdown_sync() >>> __timer_delete_sync() >>> __try_to_del_timer_sync() // looped as long as timer is running >>> >>> >>> In our case, we had in v4: >>> >>> inet_twsk_deschedule_put() >>> spin_lock(ehash_lock); >>> tw_timer_handler() >>> inet_twsk_kill() >>> spin_lock(ehash_lock); >>> __inet_twsk_kill(); >>> timer_shutdown_sync(&tw->tw_timer); >>> >>> The fix here is to move the timer deletion to a non-timer >>> context. Workqueues fit the bill, and as the tw_timer_handler() would j= ust queue >>> a work item, I converted it to a delayed_work. Does this explanation make sense? This is the reasoning that drove me to involve workqueues. I'm open to suggestions on alternative approaches.