From owner-freebsd-hackers@FreeBSD.ORG Fri Jun 6 23:20:18 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 060627B4 for ; Fri, 6 Jun 2014 23:20:18 +0000 (UTC) Received: from mail-qa0-x236.google.com (mail-qa0-x236.google.com [IPv6:2607:f8b0:400d:c00::236]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BBD882AF1 for ; Fri, 6 Jun 2014 23:20:17 +0000 (UTC) Received: by mail-qa0-f54.google.com with SMTP id j15so5041301qaq.13 for ; Fri, 06 Jun 2014 16:20:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=59wdCfdyxtuzVBEPGAn1Q14FNTIWYHc7yWuk74zvqIw=; b=dL81F+N8Xg+go7jbZOjuZ4r29V0iFIE2C+b5Q7lPQwHpBOQiTYSBvZIjCpKO89AfRt sbO3Muvn32v7wGU+wiG0baxHHlP3Oe4qgioWp+3pMWa7f2LQNxsCvZ0u0sAGlZx5PwTY e8m239yFt5KPTC5f7C3gGwxuM9IWBlRdVcuLnwb6S0NGtpOrQiRV8vZ/MXiZHE8F71nk 6+ysEKtzQbZWv11jU9hcwNckBmS4rXLWS2z/tnZDl3uy6ZR6cweQEyi/7WLD6UtC7KsO noIUx4nawRFYiVo0kUFWXOe6k/BeBmuF34AsAyXr0oObv2UnWXWzdIk7Ek8IXOJKaMXh Vm4g== MIME-Version: 1.0 X-Received: by 10.224.16.199 with SMTP id p7mr13882095qaa.76.1402096816933; Fri, 06 Jun 2014 16:20:16 -0700 (PDT) Sender: adrian.chadd@gmail.com Received: by 10.224.43.134 with HTTP; Fri, 6 Jun 2014 16:20:16 -0700 (PDT) In-Reply-To: References: Date: Fri, 6 Jun 2014 16:20:16 -0700 X-Google-Sender-Auth: sSnGXeQTWEuw9b9Ttnx9UlnhKfU Message-ID: Subject: Re: Best practice for accepting TCP connections on multicore? From: Adrian Chadd To: Daniel Janzon Content-Type: text/plain; charset=UTF-8 Cc: "freebsd-hackers@freebsd.org" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Jun 2014 23:20:18 -0000 Hi, I'm working on exactly this with the RSS support that's in the tree. The vague design I have in mind is to have one bound thread per RSS allocated CPU, and then put a listen TCP (and later UDP) socket in each thread. Then the accept path in the TCP/PCB code will do a lookup in the CPU-local PCBGROUP table first to see if there's a local listen socket in that table that's local to that CPU. If so, the request will go to that socket. I'll later add support for multiple sockets listening on the same IP:PORT entry, so you can have multiple threads load balanced (eg on the same CPU, or a small CPU set on a core local to that NIC, etc.) But that'll have to come later - it requires a slightly larger overhaul of how listen entries work in that table. I have a patchset that works and I'll be slowly merging it into -HEAD over the next week. Thanks, -a On 6 June 2014 16:00, Daniel Janzon wrote: > Hi, > > What is the best practice (performance-wise) for dispatching new TCP > connections to different threads in order to make use of multiple cores? > > Is there any better way than doing the accept() call in one thread and then > dispatch it to a thread on another core with any user space method? > > Conceivably one should be able to perform the accept() call from several > threads but using the same socket and let the kernel distribute the > incoming connections using some kind of hash or round robin. > > Regards, > Daniel > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"