Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A9DAC6FD1D for ; Thu, 16 Mar 2023 00:56:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229616AbjCPA46 (ORCPT ); Wed, 15 Mar 2023 20:56:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229516AbjCPA44 (ORCPT ); Wed, 15 Mar 2023 20:56:56 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5F5839CE7 for ; Wed, 15 Mar 2023 17:56:54 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id l1so48960wry.12 for ; Wed, 15 Mar 2023 17:56:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678928213; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=fSS+F/Bcd2QhmEMKAbEPUNmDxd0R/g869+IJjWilPDE=; b=kl3P1XmqGm/PjnhrcemaaT1eDsQbDT7OaLMbx5PrNaAOzp3piTiWS1acowvnM4T1lq 34dFYVU99ozRoktHFvDf3Cc29QPD+Xoo4LJwKooDWLA++dUfWRTCT+W8EJHD4ihJXv9+ fTjSqFBTM+Zsx8RQf1CO6lzOB/HyKDpeJYIzQpIoudeExrPyNLf1OHYt4jynAyv9PFuK 2zhttqolKCFLGw+secwV5lP/gyk7NG1tvuFv3s8g2F+yjap8mqVUhQJOLaGOmMvvGcAR ajsoOSXV05O2tYEZ6BmYDr7oyL0+psFPIzRtGgjVhnoxZ7dOlskc/V2Zi4sfn1h014y4 qBpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678928213; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fSS+F/Bcd2QhmEMKAbEPUNmDxd0R/g869+IJjWilPDE=; b=vIGjE5BeuRLlKrGJBuWVxwkXdyidXuk5vvFy5fSSlg4JQdyCrcWBPVQl5HGPfzKY9E +7jdbxUaBF5cHxV9ftB0GRJ1idlM1iArJV9vLaUUPnNuC/Tnj3Pbx/rBgzcY7V+n9Clj LV2YZW1/4cqSnswsGQRNvSvry9TD6zCdxqvDY9If0L5OSPltsyro8OEQbR0jG/0DF9VP HGDq3rwtFTxHB8u+M9PStsN6zzlUXd5KqaZXsUlclkd1ygy+Ubx3TeAIQH+MveoN1fd4 90unIzyWAIzSotJXh0vbGawjs3GfurqwDErWcuzV+M/rYDVLQhW4hO/uNCRdNL3lx4mL TOYg== X-Gm-Message-State: AO0yUKXSLLvJghM6mVKCSbDUp1AznyiDJNJykj14/5VUgnZpzKyyUVdN t3v9oDdmcPbCPZl/5CZgucwMGyHR9LYKLZpuAkg= X-Google-Smtp-Source: AK7set/jPlgH2eVqfMD55DQ8G5zEr9rlx/qG6YULKO700aK4Rotie4fqPVvrHpTzfEHwkB1W9OJsjGaSdxUsEm08eeA= X-Received: by 2002:a5d:4687:0:b0:2ce:a3a7:5d3f with SMTP id u7-20020a5d4687000000b002cea3a75d3fmr945658wrq.3.1678928213248; Wed, 15 Mar 2023 17:56:53 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: richard clark Date: Thu, 16 Mar 2023 08:56:41 +0800 Message-ID: Subject: Re: Question about select and poll system call To: David Laight Cc: "linux-kernel@vger.kernel.org" , "torvalds@linux-foundation.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 15, 2023 at 4:59=E2=80=AFPM David Laight wrote: > > > 2. Can we unify the two different system calls? For example, using > > poll(...) to implement the frontend select call(...), is there > > something I'm missing for current implementation? The Cons and Pros, > > etc > > The underlying code that implements them is common. > > Beware that the glibc select() wrappers have their own limit > on the highest fd. > Exceeding that limit (probably 1024) will cause buffer overruns > in the application (One of the Android apps I uses crashes that way). Ah, interesting. Seems glibc doesn't make that limit from my testing code snippet in last email... > > select() also doesn't scale well for sparse lists of fds. > So it really is best to use poll() and never select(). > (Although for very large fd lists epoll() may be a better choice.) > > David > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1= 1PT, UK > Registration No: 1397386 (Wales)