From mboxrd@z Thu Jan 1 00:00:00 1970 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F51AC433F5 for ; Mon, 31 Jan 2022 18:04:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 978988D0018; Mon, 31 Jan 2022 13:04:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 928098D0001; Mon, 31 Jan 2022 13:04:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F0BF8D0018; Mon, 31 Jan 2022 13:04:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0120.hostedemail.com [216.40.44.120]) by kanga.kvack.org (Postfix) with ESMTP id 725D58D0001 for ; Mon, 31 Jan 2022 13:04:29 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 25E2780C45F7 for ; Mon, 31 Jan 2022 18:04:29 +0000 (UTC) X-FDA: 79091357058.29.6631A72 Received: from mail-yb1-f175.google.com (mail-yb1-f175.google.com [209.85.219.175]) by imf09.hostedemail.com (Postfix) with ESMTP id C0C5B14001B for ; Mon, 31 Jan 2022 18:04:28 +0000 (UTC) Received: by mail-yb1-f175.google.com with SMTP id i10so42995555ybt.10 for ; Mon, 31 Jan 2022 10:04:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jKOkqEsF/LF5CvREpOhl/oWeS4V81mya8jnYw1wCDFw=; b=ZoEoPhFI/SkB8VO31hL0sxmvpM9bvkaNazc4+33voZ+d+Jq5CVfcf/4q4i0xfFVF+K 6K3x1JC51OSZS84XuLrcAnSAKYqNlF3njdyY4m4M/pKKeCHTbzs+Xq85lzme9M8UxF4I 1WfKC4mIWOsksRwShjtGW08RG0g2y8tChKAdjmFXp7Q3TjfNzMl9p/WhNHEqW/+QkIFr Yr5a3t+LeDzoi58dWsvqQRJ8qK6GGOHZzpXWEpXhYHvp2noblx7S6Gzn1tb7BLZHKN7X e23AKSODY44B7jDfGz4rsRiFIXwRylsE/dpWc9z9mafZeHrt3om02GsVon7YI8i/miOP c+Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jKOkqEsF/LF5CvREpOhl/oWeS4V81mya8jnYw1wCDFw=; b=LsF3VzvbuLhhb40IjrcmqYQ9Ya+A/evv7vZ1hPMrAjT3xNFwFP65LLtysMGqr/Hlcm ellA7SbtefM9XmkrEqNwvomxRitYZzJjr+o2fY0bX7wE+QsuIpHuw+vmsmmZuu7XR21H +fb486dX66Ba+zbuCnZPxVvHfsYyzTVPrOjyHvvJyZeKLnawGMQT/z1WkR8yfpDQWLkW wQ7IE5aVhj1y4lJEACfPIEW4m4KdMyq01hJaO4k8dX3397VXF4QcuXR7XFWFHxzkGyjH 7xnqGvaZ6Vn4XmAtD51Yqh6g86OyWxunMCFC1U621tKtt+ubIWHWuLgePAlKXMB/RVAZ w5ZA== X-Gm-Message-State: AOAM530HAeSg7P/oVWxZpDn4rTE3apXbhwVbUGAnJmPtf1gHKPYM0q+R jR3qsx9PkXToSOOq3/VwmyigSDl/riuOdbCF/UGwkA== X-Google-Smtp-Source: ABdhPJxSm9PiQ3U9z6FjArWXy90UeaLFc3caonzQOEh5hkATCDM1i9WF3dnhHFARISw+yK8dDaKgygwIlt49Rck/uf0= X-Received: by 2002:a25:be41:: with SMTP id d1mr33068235ybm.488.1643652267644; Mon, 31 Jan 2022 10:04:27 -0800 (PST) MIME-Version: 1.0 References: <20220128131006.67712-1-michel@lespinasse.org> <20220128131006.67712-23-michel@lespinasse.org> <20220129121319.3593-1-hdanton@sina.com> In-Reply-To: <20220129121319.3593-1-hdanton@sina.com> From: Suren Baghdasaryan Date: Mon, 31 Jan 2022 10:04:16 -0800 Message-ID: Subject: Re: [PATCH v2 22/35] percpu-rwsem: enable percpu_sem destruction in atomic context To: Hillf Danton Cc: Michel Lespinasse , Linux-MM , LKML Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: 6kipfgyajkx1u6g7jbuf779noz19hypy X-Rspam-User: nil Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=ZoEoPhFI; spf=pass (imf09.hostedemail.com: domain of surenb@google.com designates 209.85.219.175 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: C0C5B14001B X-HE-Tag: 1643652268-195365 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat, Jan 29, 2022 at 4:13 AM Hillf Danton wrote: > > On Fri, 28 Jan 2022 05:09:53 -0800 Michel Lespinasse wrote: > > + > > +static LIST_HEAD(destroy_list); > > +static DEFINE_SPINLOCK(destroy_list_lock); > > static bool destroyer_running; > > > + > > +static void destroy_list_workfn(struct work_struct *work) > > +{ > > + struct percpu_rw_semaphore *sem, *sem2; > > + LIST_HEAD(to_destroy); > > + > > again: > > > + spin_lock(&destroy_list_lock); > > if (list_empty(&destroy_list)) { > destroyer_running = false; > spin_unlock(&destroy_list_lock); > return; > } > destroyer_running = true; > > > + list_splice_init(&destroy_list, &to_destroy); > > + spin_unlock(&destroy_list_lock); > > + > > + if (list_empty(&to_destroy)) > > + return; > > + > > + list_for_each_entry_safe(sem, sem2, &to_destroy, destroy_list_entry) { > > list_del(&sem->destroy_list_entry); > > > + percpu_free_rwsem(sem); > > + kfree(sem); > > + } > > goto again; > > +} > > + > > +static DECLARE_WORK(destroy_list_work, destroy_list_workfn); > > + > > +void percpu_rwsem_async_destroy(struct percpu_rw_semaphore *sem) > > +{ > > + spin_lock(&destroy_list_lock); > > + list_add_tail(&sem->destroy_list_entry, &destroy_list); > > + spin_unlock(&destroy_list_lock); > > + schedule_work(&destroy_list_work); > > Nits > spin_lock(&destroy_list_lock); > 1/ /* LIFO */ > list_add(&sem->destroy_list_entry, &destroy_list); > 2/ /* spawn worker if it is idle */ > if (!destroyer_running) > 3/ /* this is not critical work */ > queue_work(system_unbound_wq, &destroy_list_work); > spin_unlock(&destroy_list_lock); Thanks for the review! Just to clarify, are you suggesting simplifications to the current patch or do you see a function issue? > > +} > > -- > > 2.20.1 >