From nobody Sun Feb 8 02:21:50 2026 Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) (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 AC8D01AED55 for ; Thu, 4 Jul 2024 15:19:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720106366; cv=none; b=PNcJrg0SXeAtatLdUCbM6BP4XHdHfvzvQjv6XNSLJU78baXPKpNc61EUdWJRkAc82JAqqyNZN2GzRS4DiiigK8aAX2Km6GOFVbHujKkA2a3RnPijXesCo2XrSTdTgt3WbBhTfQcHY5n4rO7avDKzJkVeM+OfzXLq5EiRw0FOrsQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720106366; c=relaxed/simple; bh=GW7lGQVvoINycqpkDuvFso5boq2/G2LMAD35CBY3e+Y=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=ofZ7A2M1u0Njj5P6HCven1WNWePGbiykPBJaI+pyzkqY0ypY+y1GPeBiiTA+uRWxP0K59+JKQ6lsnWMxHVgSdVQxjRREH4CT615HSIIxoF9uGacJLrvX9AQIJZIoLeLRrW8/0fmPgEW9zV3AxflUwACHI7+MjX/HQyJCv1WOiFQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=mW/GZCwd; arc=none smtp.client-ip=209.85.210.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="mW/GZCwd" Received: by mail-ot1-f52.google.com with SMTP id 46e09a7af769-701fb69e406so415132a34.3 for ; Thu, 04 Jul 2024 08:19:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720106364; x=1720711164; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=sNuQK2cmBkSQYJ6c7VDkHOb8OIuBPIO52OK/qSuYR/Q=; b=mW/GZCwdMLuDCYGHfBumEj2WD7SxreB62nSDklaqbApugm9/RaOiK4bbQVQRNByIs2 ssG3T4Dq/fO+Z65sLxzPcWweLic064yhcs0p71aaQ7KIMv5p/nbCL98VE+xzLtGJFHJo CQ4SynEF6t9GpRfphbr5qrJA4tYs3Pwwm0D42ywT300Pfrnc+xuHn8D02+MS9Nt5VhIk zT6ET+ofEwqRRv9LWGzr5p4oWEZsJmOIcxKd9yi3vm/zO4QjH7ADG5ZqgzRSaeK266zm aIlAPpG5gB1YtSLywpR+MbqDfimZ3YUxf4Ce0VhhJ0ibwB5Bf/mdMmWIx2Xhsz8ljKwZ RWVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720106364; x=1720711164; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=sNuQK2cmBkSQYJ6c7VDkHOb8OIuBPIO52OK/qSuYR/Q=; b=k4KFQ6upFP7Bt3U7493Nx04Y4lSMu9g0hC9iun9tuoFcHaZyXiBxFddNmmTVELtljV DfRvKHb7kZDeMUIwQQxRt1KkLRsNLa7C0MnbiWuHVjDU+XDKZ+DWzdX/9xJFNMT+IPxP vG1T0VF/OAJxKwgaiVGhuw2u4tJw12TLudF+doeYVIB/lVu3r8d2jNmunA64yGD9G1A+ wn8/mfU8LdAtwgD4D6Mc25/iVnLPUF01aM/Idq/66YM7eD0zAIUJy4QbOWr/R26CunRc bpjIorC0b560g2dCDe1KKI/q2g1W0qJMbnWsgvlFaDuldUhVxcaSy2ybZkl+s9FP5eF2 jxHg== X-Forwarded-Encrypted: i=1; AJvYcCWCpR6/hK7yK/G43vaoMbKqp4W3sa/wgr/zdSCn93DSc59lxEwaeryaeIoTj66QLLXM0JlILzyxR6tSrlZh8Ge7mQeIVOaNqLMYb/Zy X-Gm-Message-State: AOJu0Yxn/Ih5BMjHrReajB53xbBsurKxTGDbaO9iGIaNfR3DEmhTX2bn GOlQtVPTKHfUdDvN6oK0cRf51sLp7X+6oPAlgKisrhdlKQa5tL9WiLc0JFY6HUI= X-Google-Smtp-Source: AGHT+IFOSX1RgZBOPwSdETXKnceKwdzsvK0Bgb6C66NIKvTohb08sSlA2qq83eKVPmd1LfCeS+jAvQ== X-Received: by 2002:a05:6870:171e:b0:254:8ca4:a189 with SMTP id 586e51a60fabf-25e2bb48b9emr1726668fac.17.1720106361830; Thu, 04 Jul 2024 08:19:21 -0700 (PDT) Received: from localhost ([2603:8080:b800:f700:96a0:e6e9:112e:f4c]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-25d8e339b40sm3259752fac.43.2024.07.04.08.19.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jul 2024 08:19:21 -0700 (PDT) Date: Thu, 4 Jul 2024 10:19:19 -0500 From: Dan Carpenter To: Yonghong Song , Christian Brauner Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH bpf-next] bpf: remove unnecessary loop in task_file_seq_get_next() Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" After commit 0ede61d8589c ("file: convert to SLAB_TYPESAFE_BY_RCU") this loop always iterates exactly one time. Delete the for statement and pull the code in a tab. Signed-off-by: Dan Carpenter Acked-by: Jiri Olsa Acked-by: Yonghong Song Reviewed-by: Christian Brauner --- kernel/bpf/task_iter.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/kernel/bpf/task_iter.c b/kernel/bpf/task_iter.c index ec4e97c61eef..02aa9db8d796 100644 --- a/kernel/bpf/task_iter.c +++ b/kernel/bpf/task_iter.c @@ -261,6 +261,7 @@ task_file_seq_get_next(struct bpf_iter_seq_task_file_in= fo *info) u32 saved_tid =3D info->tid; struct task_struct *curr_task; unsigned int curr_fd =3D info->fd; + struct file *f; =20 /* If this function returns a non-NULL file object, * it held a reference to the task/file. @@ -286,12 +287,8 @@ task_file_seq_get_next(struct bpf_iter_seq_task_file_i= nfo *info) } =20 rcu_read_lock(); - for (;; curr_fd++) { - struct file *f; - f =3D task_lookup_next_fdget_rcu(curr_task, &curr_fd); - if (!f) - break; - + f =3D task_lookup_next_fdget_rcu(curr_task, &curr_fd); + if (f) { /* set info->fd */ info->fd =3D curr_fd; rcu_read_unlock(); --=20 2.43.0