Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3228395imw; Mon, 11 Jul 2022 04:46:22 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uJuVJnhVDgr+ZWJeDuxghpuP5dBde+CMQiEd2RAs/skS1fyeHpH8LHYSrbdAC298Yvnl2S X-Received: by 2002:a17:90a:f813:b0:1ef:8a65:3b7 with SMTP id ij19-20020a17090af81300b001ef8a6503b7mr18095162pjb.72.1657539981997; Mon, 11 Jul 2022 04:46:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657539981; cv=none; d=google.com; s=arc-20160816; b=gyU0PtuvgY8kJimd4F/C6KW/0oT9CFC3s2nIfnCaqV2bGY7jWc03aUkVKJyJlTdhGA tmUWddJosUrE+zI8rfw78mZOuwK5hl2lerfSCX9BACgp1ZiGoQDVwMDD1Eamp6r0iejA 0uJxFcu+eUNXSimt0+ScrHIyYyGC9DjpO33iV6Trsilq6c0xFynX5XcMuQlyMZ1WLO2F 4Ma9oHDgvRxWdHCL3aS9XyTn/kvca13+NBB3HBsL/xBD29jjkYh7Yp14aiTSPeHjw4/5 p5V0YCzAka+elXV5e5YwOqZtIClgHjqbcsJLxGsPZUmWRuhE2lhPZWHj7jryqzv27PJd jHzg== 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=gHZTeBa+zo6V5aGVigu7pGUwqHAZBzzfDHWLTO9INzI=; b=tVQUx5FxpJBDmvhbsoWhmpwBQO4W91nglXgYfLeav0RBlueX13qGQJ8BvGCovDN+0I t+eXpJpA6rcHy0YsuU1DsQGCrV4qsUnB/hztfy53kIJ/y81XWS9R2TBTj/5MCQRZF9DM u2VlL/3QgDBa96u2FZQVkCdDkRbQ6RWxkhF0H5qhbCaHBBHWziWF+uQIBl3q4X7w/KAP 9oUjyi39CHborpbarOAhwcJ9RQr8c/AqjzPnpZ5fwi8JCi05Zaouong6rFJeC0OMTRHc dSu9Xmgy78kSxX6FLzkl91K/IeHvNW9LWKsP80CSUvCLBJXrvxaM8p//uD3B4Vu6FtU2 GhbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VnME6Q7n; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u13-20020a170902e80d00b0016c056e7a4csi11210938plg.523.2022.07.11.04.46.12; Mon, 11 Jul 2022 04:46:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VnME6Q7n; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230519AbiGKLpM (ORCPT + 64 others); Mon, 11 Jul 2022 07:45:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231159AbiGKLox (ORCPT ); Mon, 11 Jul 2022 07:44:53 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5652F381 for ; Mon, 11 Jul 2022 04:41:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657539675; 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=gHZTeBa+zo6V5aGVigu7pGUwqHAZBzzfDHWLTO9INzI=; b=VnME6Q7nQgsS30ursDvkPyRslJgOQr0nbpJ0wrgV7GYn0ryV7GTKcRewRXhwLpiQdxoUmV 7zKQfHzB/yj9wy1rDgsNWLiF4sARvsZJpK4e6QJ9Krzk6V0+j3IPQq3VlnrUxueHmO2Yha NUImyKaBKh8gmd1o+YoVn2DtHKTcurE= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-149-SmnO3v3DOXOY2Wtv3eKn_g-1; Mon, 11 Jul 2022 07:41:14 -0400 X-MC-Unique: SmnO3v3DOXOY2Wtv3eKn_g-1 Received: by mail-wm1-f70.google.com with SMTP id q15-20020a05600c040f00b003a2e5c8fca3so1905728wmb.7 for ; Mon, 11 Jul 2022 04:41:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=gHZTeBa+zo6V5aGVigu7pGUwqHAZBzzfDHWLTO9INzI=; b=qGxGoXRA6+JWvBgqX/qmLQyEc8CpMgHkeEmlOgZiAYLuEQGkmfc8q7upzr389PFTIL agFmlRzmk9UoqE5ph4Bx6fM+6L7f0eb7CAowTmM95Dx2JbJsuc2AdK/jjE9ikgavDWYC IoWj2sgXs66xXO5grWZaD/1BGjlDZ1rj9/O/IxO8Dj6Gdekwpjd5IXXs2IMc8xbwOSAw xFWmstKaUQNgKa8mAJ8Xf0pSTfcLBGLHwm+EEc43bS5ftHcbs5RoTEjz4pGv0/pcW5UT RvSaLuFFIgp7138IVuZMl9GZPnP7savwisvnVU63L5BEuscq9X8dRSafsutnjSPYGnq4 6VlA== X-Gm-Message-State: AJIora9Eau8NOuJvl0gGXyQZiKPLEV28eamrWA+Npz2Sus6eA9CLgokn iqjl36Oe+RpQeBppS0Wh78AYyT6bUP0d1RwWGBV9bIjtFqcJtKqd2Nyzz4oum7ANv73HShzfALW P7vZC9wXTVf0uxBnxwZC/TsjfxYA= X-Received: by 2002:adf:fbc6:0:b0:21d:3fc3:99e with SMTP id d6-20020adffbc6000000b0021d3fc3099emr16603231wrs.550.1657539673361; Mon, 11 Jul 2022 04:41:13 -0700 (PDT) X-Received: by 2002:adf:fbc6:0:b0:21d:3fc3:99e with SMTP id d6-20020adffbc6000000b0021d3fc3099emr16603219wrs.550.1657539673173; Mon, 11 Jul 2022 04:41:13 -0700 (PDT) Received: from vschneid.remote.csb ([185.11.37.247]) by smtp.gmail.com with ESMTPSA id u20-20020adfa194000000b0021da61caa10sm2434566wru.56.2022.07.11.04.41.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 04:41:12 -0700 (PDT) From: Valentin Schneider To: Kalle Valo , "Jason A. Donenfeld" Cc: Herbert Xu , linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, Gregory Erwin , Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= , Rui Salvaterra , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Christian Brauner , linux-crypto@vger.kernel.org Subject: Re: [PATCH v8] ath9k: let sleep be interrupted when unregistering hwrng In-Reply-To: <87v8s8ubws.fsf@kernel.org> References: <20220629114240.946411-1-Jason@zx2c4.com> <87v8s8ubws.fsf@kernel.org> Date: Mon, 11 Jul 2022 12:41:12 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On 07/07/22 19:26, Kalle Valo wrote: > "Jason A. Donenfeld" writes: > >> There are two deadlock scenarios that need addressing, which cause >> problems when the computer goes to sleep, the interface is set down, and >> hwrng_unregister() is called. When the deadlock is hit, sleep is delayed >> for tens of seconds, causing it to fail. These scenarios are: >> >> 1) The hwrng kthread can't be stopped while it's sleeping, because it >> uses msleep_interruptible() instead of schedule_timeout_interruptible= (). >> The fix is a simple moving to the correct function. At the same time, >> we should cleanup a common and useless dmesg splat in the same area. >> >> 2) A normal user thread can't be interrupted by hwrng_unregister() while >> it's sleeping, because hwrng_unregister() is called from elsewhere. >> The solution here is to keep track of which thread is currently >> reading, and asleep, and signal that thread when it's time to >> unregister. There's a bit of book keeping required to prevent >> lifetime issues on current. >> >> Reported-by: Gregory Erwin >> Cc: Toke H=C3=B8iland-J=C3=B8rgensen >> Cc: Kalle Valo >> Cc: Rui Salvaterra >> Cc: Herbert Xu >> Cc: stable@vger.kernel.org >> Fixes: fcd09c90c3c5 ("ath9k: use hw_random API instead of directly dumpi= ng into random.c") >> Link: https://lore.kernel.org/all/CAO+Okf6ZJC5-nTE_EJUGQtd8JiCkiEHytGgDs= FGTEjs0c00giw@mail.gmail.com/ >> Link: https://lore.kernel.org/lkml/CAO+Okf5k+C+SE6pMVfPf-d8MfVPVq4PO7EY8= Hys_DVXtent3HA@mail.gmail.com/ >> Link: https://bugs.archlinux.org/task/75138 >> Signed-off-by: Jason A. Donenfeld >> --- >> Changes v7->v8: >> - Add a missing export_symbol. >> >> drivers/char/hw_random/core.c | 30 ++++++++++++++++++++++++---- >> drivers/net/wireless/ath/ath9k/rng.c | 19 +++++++----------- >> kernel/sched/core.c | 1 + >> 3 files changed, 34 insertions(+), 16 deletions(-) > > I don't see any acks for the hw_random and the scheduler change, adding m= ore > people to CC. Full patch here: > > https://patchwork.kernel.org/project/linux-wireless/patch/20220629114240.= 946411-1-Jason@zx2c4.com/ > > Are everyone ok if I take this patch via wireless-next? > Thanks for the Cc. I'm not hot on the export of wake_up_state(), IMO any wakeup with !(state & TASK_NORMAL) should be reserved to kernel internals. Now, here IIUC the problem is that the patch uses an inline invoking wake_up_state(p, TASK_INTERRUPTIBLE) so this isn't playing with any 'exotic' task state, thus it shouldn't actually need the export. I've been trying to figure out if this could work with just a wake_up_process(), but the sleeping pattern here is not very conforming (cf. 'wait loop' pattern in sched/core.c), AFAICT the signal is used to circumvent that :/