Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1109745pxb; Tue, 8 Feb 2022 09:27:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+Q4tECduox2j63+RB1ZaX1xKX06vH5rE/31qg1v1Y4gEIfatLfB646MEoqbrY7Bd0WrpH X-Received: by 2002:aa7:c154:: with SMTP id r20mr5470243edp.183.1644341253488; Tue, 08 Feb 2022 09:27:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644341253; cv=none; d=google.com; s=arc-20160816; b=A3FBluT8uDslnGJL+ZmYXYawuWgizsVyzHoCFzzOBVatDsPOOl9TpeqDtj79Cos48z PAJ2+Usu1hJgCmm9QszoYLzKZhnpu3TBOc86mx5wFaEJ2HFHE4Wkmmg4oS9vS7tHA8eg PfWascz2xKEmYOeTCRIXVel/eH1ShkwS0fX821/bai3cP5FSDgNXxt/EZuEaYQK5UjPQ JEpSq8EtrzGOUYuefBM7JT/oFvbr+oxaVXyVSSg/P8TsjjlHyzoyNZkZ/ZuPTh/fU+XA E33oYNBGLwwvDydT+vRVO+lJ1D7IkUk9QtAVF8hCDLIqUNyaRirfook+IVLHgONxCsEp o1KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=1gSrOa55TE+xa5Ovu18B/xIJNxdc0rLEc+vfv3wsOPw=; b=veaaXLG4sKhGM4s8imOgEx5spBX658y+IIRrDXEAZdTxJYKp+4Fsq4LSRm8T3VUXnN 9U5nO0zwbXK8JrL60JBXhbuU6ddl8+XLznSJCHCaTLB8oZizhu09WX/JjqEWGslrE/E4 YZZbY2lYCeU5KyRsl0xA/m5Yly9Nx7KGnqApupEjz/0LyARWx+hmfctnNoSp0fVZLvkR OFKYxMsBY8PPxLmJzzf5rgO1fYP1d98Hi+ZT7rhX2+7bD6Tboil45D4vyntEhayFXl3s KppK+/yeHR/VaLfBAOEw49Ds2VaUDmhWoBAjZorOXIQTKcGEeXMmLshM9VTydiAp+Neu Jz6w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji7si10072366ejc.39.2022.02.08.09.27.08; Tue, 08 Feb 2022 09:27:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378977AbiBEECa (ORCPT + 99 others); Fri, 4 Feb 2022 23:02:30 -0500 Received: from mail-pl1-f172.google.com ([209.85.214.172]:42886 "EHLO mail-pl1-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239965AbiBEEC3 (ORCPT ); Fri, 4 Feb 2022 23:02:29 -0500 Received: by mail-pl1-f172.google.com with SMTP id l13so6772960plg.9 for ; Fri, 04 Feb 2022 20:02:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=1gSrOa55TE+xa5Ovu18B/xIJNxdc0rLEc+vfv3wsOPw=; b=gVrhMSy6ySQjBkDG6DNxEf8eOB4XVqZkMbghmcAM/8CT40RTIA1jgjnweUKa4Aawk7 gzIO3xxFz/AtNxyiVOOJXYrG5hKVALNgjvftIbhkYPT3RUO8cfcQb5lmYn/jLK/MIMBA Cz4ZStxEe56g1Xk2rRIlO3okFnsoA6ogBlkge3nG1qtPWwvVPaq47UpCD5rIebFUDKXw kwnxi2s3EB6HCAadmqZ2HrzLABQ/twBBcsmpY2IJTPqt2lEaCbH5ywyEHjGaDqH0amQY 0XEr7E1s07lAfRq74UYtPdIQH8/9K1sjVt5QXwiGa2ZpXiR8ub2j4ZyQGT0o0jWtHuTP +XLQ== X-Gm-Message-State: AOAM531SiXU8xcaN4ySZYJkCCoGemB2OgGW0Eo/aoedYu7w0xF266Sci jAWv/LwbpgSYEDRltE2LjkE= X-Received: by 2002:a17:90b:3810:: with SMTP id mq16mr6759582pjb.95.1644033749360; Fri, 04 Feb 2022 20:02:29 -0800 (PST) Received: from sultan-box.localdomain ([204.152.216.102]) by smtp.gmail.com with ESMTPSA id l2sm4247707pfc.183.2022.02.04.20.02.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 20:02:28 -0800 (PST) Date: Fri, 4 Feb 2022 20:02:26 -0800 From: Sultan Alsawaf To: Sebastian Andrzej Siewior Cc: "Jason A. Donenfeld" , linux-kernel@vger.kernel.org, Thomas Gleixner , Peter Zijlstra , Theodore Ts'o , Jonathan =?iso-8859-1?Q?Neusch=E4fer?= Subject: Re: [PATCH RFC v1] random: do not take spinlocks in irq handler Message-ID: References: <20220204153149.51428-1-Jason@zx2c4.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 04, 2022 at 09:47:23PM +0100, Sebastian Andrzej Siewior wrote: > No need for atomic. If this is truly per-CPU then there will be no > cross-CPU access, right? > Therefore I would suggest to use __this_cpu_inc_return() which would avoid > the sync prefix for the inc operation. Same for __this_cpu_or(). And you > could use unsigned int. Hi, The __this_cpu_{ATOMIC_OP}() functions are for atomically performing a single per-CPU operation for the current CPU from contexts that permit CPU migration. Since this code is safe from CPU migrations (add_interrupt_randomness() runs in hardirq context), the atomic per-CPU helpers are unneeded. Instead of using __this_cpu_inc_return() and __this_cpu_or(), we can operate on the per-CPU pointer directly without any extra safety (e.g., `++fast_pool->count` can be used in place of `__this_cpu_inc_return(irq_randomness.count)`). Sultan