Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3855653rdg; Wed, 18 Oct 2023 07:59:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHqeP1ax7NPPQJZSIIHi9s3XPNgEP48dIcDHdCl5mysffL9oVl1HTxAsqh5RqwHQDnsbbH4 X-Received: by 2002:a17:90b:2308:b0:27d:3a34:2194 with SMTP id mt8-20020a17090b230800b0027d3a342194mr5321599pjb.14.1697641150145; Wed, 18 Oct 2023 07:59:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697641150; cv=none; d=google.com; s=arc-20160816; b=zWJKQKr/PVkuEKSvA3E7L9OluNqTFDbuMttYJDZx5ef6s3zpK7aeuNTT9cGVkJHoF+ 8O/FPxo9bFw7y1CAp7g5O8qgSGsruDdojhtP5fRTRv2047790exrTMSCV+aafBnyIjEZ ZuajQPimCLmEZeQXa4+ZdwLr7Rp4kds8fSFecoi178/HnBXlsBsrCT6WT7ta6s7kjORX 7n8kf1H9HWScssWjgXaDtya7UQuId8SK16ggEvFuHm6+iHzb40duozEx6vteZn9KHrS8 bu+bHH0UZLSeOKzV6ih//0dyUTacgNrv+MI50glOJwGQRUUuxBa6QMKWP8cRsDUd1BE/ F8ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=929sHe0GqloPiKWV58z9G1yiEL0iCqJOnGu3b5vkn9k=; fh=/xhuPbj6vnsbghDAHO1MSD10zlat3lGeSqWIE/DHFbI=; b=ql+e6g/5XPtO5I8OVaZez1iHcmLJBaB2lbNbhxknrWyzugOIrhTGRjN9oX2ksQAObK owQJM854FEiDVXuhJsnWNuZtsWLAR0wQfisCstREd/uESmhmlb/1k9D0KNwhWU/c4lPu bCFwRqxXSr34aPP1yjRcUj5aNnToXM9HDKz25doZSvOxV/np4eey+dvrtxTpHm3z/t/m R3MgAhsjkWI8UVXeM6Pduhk8sxNhwU+Uxl55HeO/+AIfKV3ZQkiV+IPURbnXJRIpGuqL A6X+19KNOahmMSG420FlyTzxL/jG9Bt/9yl6jmCqdZfX2ZQA4PJJagEoZ9bLC0I9rjS0 6sjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=A4bb7bUh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id qe3-20020a17090b4f8300b00278f81e54cdsi57246pjb.19.2023.10.18.07.59.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 07:59:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=A4bb7bUh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 718FF8029337; Wed, 18 Oct 2023 07:59:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345118AbjJRO6f (ORCPT + 99 others); Wed, 18 Oct 2023 10:58:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345110AbjJRO6c (ORCPT ); Wed, 18 Oct 2023 10:58:32 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87988AB for ; Wed, 18 Oct 2023 07:57:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697641064; 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=929sHe0GqloPiKWV58z9G1yiEL0iCqJOnGu3b5vkn9k=; b=A4bb7bUhGrgHuTJ2c72Guo7cEBbg6E4we7jeScY8XKmfu43w20QbOfxjI6+Xe/FYPm/Q52 LmFwlhjlGRLbyh9+MHJhaMMij2CNgvoK/0yCbWKo59wH8LT6JLEDq2ZFk0oHwQKzl3Ai/1 5f6yEz/NFTcxtRSf0MhV+dPVcAt5jKA= Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-50-hUwTqb5yP-qeV-ePC461Ew-1; Wed, 18 Oct 2023 10:57:43 -0400 X-MC-Unique: hUwTqb5yP-qeV-ePC461Ew-1 Received: by mail-oi1-f199.google.com with SMTP id 5614622812f47-3af5aa51bacso9586184b6e.3 for ; Wed, 18 Oct 2023 07:57:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697641062; x=1698245862; 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=929sHe0GqloPiKWV58z9G1yiEL0iCqJOnGu3b5vkn9k=; b=cKL0shmYttEjgKSzwGOEI7oHTJBwMNqUFiWvqXiJMiI4gSPRADNkj+f7FWshJXPNSP zRROtuMSQvHmSF/ccCrnTwa+DywLY+lKAlijZf6bob4B/avBQltJfd08/MMZRpn/u++9 GSbaNgn7gkWxB61A4ZvplVStMh8XACxjF2b1tQlWPHPI/baYNxIzy3P3TOFZKkrHGkYf 15mCcb+/yKjVev7QTQ/BF+ZwJqQFxCfDMRjWXPV+Yr/a2J3T3I5jcEvvmTmhZ0XQjker bKrx4nRyyGd/fW/5NdZVRDI1w81CqgzIqd19t5i4d2cb9+6/0wWJOzSDljr3gQp0HNDk uArg== X-Gm-Message-State: AOJu0YwDCXWuJUIXJTgJlbVkRdkb0tH+AYtbtftPw2nfW+TgOC+kUHUW 6nFVL2y6tgQXwjtrP8KSFk/+Wde7Y51WBleZnIFZ5LivuyQo4nCf5tJ/Xn6ee2BDibz4m5VAhqb 4D6CnNToQP+DS6l9lytNBBAdr X-Received: by 2002:a05:6808:685:b0:3a9:e8e2:57a7 with SMTP id k5-20020a056808068500b003a9e8e257a7mr5130532oig.53.1697641062542; Wed, 18 Oct 2023 07:57:42 -0700 (PDT) X-Received: by 2002:a05:6808:685:b0:3a9:e8e2:57a7 with SMTP id k5-20020a056808068500b003a9e8e257a7mr5130514oig.53.1697641062140; Wed, 18 Oct 2023 07:57:42 -0700 (PDT) Received: from vschneid.remote.csb (213-44-141-166.abo.bbox.fr. [213.44.141.166]) by smtp.gmail.com with ESMTPSA id bl31-20020a05620a1a9f00b00767d4a3f4d9sm15800qkb.29.2023.10.18.07.57.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 07:57:41 -0700 (PDT) From: Valentin Schneider To: Eric Dumazet Cc: dccp@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "David S. Miller" , Jakub Kicinski , Paolo Abeni , David Ahern , Juri Lelli , Tomas Glozar Subject: Re: [RFC PATCH] tcp/dcpp: Un-pin tw_timer In-Reply-To: References: <20231016125934.1970789-1-vschneid@redhat.com> Date: Wed, 18 Oct 2023 16:57:39 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=0.6 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 18 Oct 2023 07:59:06 -0700 (PDT) On 16/10/23 17:40, Eric Dumazet wrote: > On Mon, Oct 16, 2023 at 3:00=E2=80=AFPM Valentin Schneider wrote: >> >> The TCP timewait timer is proving to be problematic for setups where sch= eduler >> CPU isolation is achieved at runtime via cpusets (as opposed to statical= ly via >> isolcpus=3Ddomains). >> >> What happens there is a CPU goes through tcp_time_wait(), arming the tim= e_wait >> timer, then gets isolated. TCP_TIMEWAIT_LEN later, the timer fires, caus= ing >> interference for the now-isolated CPU. This is conceptually similar to t= he issue >> described in >> e02b93124855 ("workqueue: Unbind kworkers before sending them to exit(= )") >> >> Making the timer un-pinned would resolve this, as it would be queued onto >> HK_FLAG_TIMER CPUs. It would Unfortunately go against >> ed2e92394589 ("tcp/dccp: fix timewait races in timer handling") >> as we'd need to arm the timer after the *hashdance() to not have it fire= before >> we've finished setting up the timewait_socket. >> >> However, looking into this, I cannot grok what race is fixed by having t= he timer >> *armed* before the hashdance. > > That was because : > > 1) the timer could expire before we had a chance to set refcnt to > a non zero value. I guess this is fine if we use an extra atomic decremen= t. > > OR > > 2) another cpu could find the TW and delete it (trying to cancel the > tw_timer) before > we could arm the timer. ( inet_twsk_deschedule_put() is using > del_timer_sync() followed by inet_twsk_kill()) > > Thus the tw timer would be armed for 60 seconds, then we would have to > wait for the timer to really > get rid of the tw structure. > > I think you also need to change inet_twsk_deschedule_put() logic ? > Gotcha, thank you for pointing it out. >> Keep softirqs disabled, but make the timer un-pinned and arm it after the >> hashdance. Remote CPUs may start using the timewait socket before the ti= mer is >> armed, but their execution of __inet_lookup_established() won't prevent = the >> arming of the timer. > > OK, I guess we can live with the following race : > > CPU0 > > allocates a tw, insert it in hash table > > CPU1: finds the TW and removes it (timer > cancel does nothing) > > CPU0 > arms a TW timer, lasting > Looks reasonable to me, I'll go write v2. Thanks for the help!