Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp893301img; Fri, 22 Mar 2019 10:48:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqyns8rikTKEMjgU4qNI16rwucuX2q/DhyvOoWVSlyz6MhbQg+Vn8rM6msKDPCIeo9mHEtzW X-Received: by 2002:a62:5543:: with SMTP id j64mr10404583pfb.105.1553276910791; Fri, 22 Mar 2019 10:48:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553276910; cv=none; d=google.com; s=arc-20160816; b=CVwTk5gS09LWpGuzX8Qjytlu4+eAbR2kw9eh67Xz3FHTdX0Ec5BTnLSCiqTG8HHtZs f5PThioELVJdb6/cyrOTk8Qv6uAoS4WV0iD0+ellySZxGPskEPnpw841Xuc9rz6CIvnm lRdkSNfcJdN7PG3pSbEI9kj0IAaBTyc6PBWZmdAj5lXFytUb9cyOfhBA04+l0Ub4aYdq 1xjMN/y2yKZMxqgVRnUnT0SDG/+JNaLTZOXiFoYPRU8dKr4KQlC0f1aAaz11vsyxoIDX elOpOhXLk3bNcOfLBWx0fp3B1kc/jFKnH+Ir5Y7dFnr8r6e8QxrPBkld99wWCYkD+0Ij L2PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:feedback-id:mime-version:user-agent :references:message-id:in-reply-to:subject:cc:to:from:date :dkim-signature; bh=rFwzn/BBO25AP0s77MXmb0hXGtOvd/fOwhwfuRoZrBw=; b=tRhqOioncaPPdL7OPs/kqMwnf3hvk1c2TfXB1ukfWjCsslCGVf0cbKN56xmqQndvfp DBEZwAovSnKxJofD81KY/nrNOfljYUUmXcy4pRSikHKuWqopFXA+malfTh651ji7Ge3y NPfAZZVjqueTQfEdNRTef0SD42sdJ65Mr+j7iPa1A0h9obFJI3qwbGkoQYP0ce66dGVW E51mNNtj7P5QwVuu113AeigcL1yHf37XwT0PovIvVBcjv/lEInkpkIvOx9H+tYuYkPgp JbOELLzZFk2MX7dC8H17vaW4UG+VhONZSedU2+W2KXj43lh50qaS783EqTYNkMMVoWim PdIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazonses.com header.s=6gbrjpgwjskckoa6a5zn6fwqkn67xbtw header.b=C9e2KlVV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b2si1630498pgt.494.2019.03.22.10.48.15; Fri, 22 Mar 2019 10:48:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amazonses.com header.s=6gbrjpgwjskckoa6a5zn6fwqkn67xbtw header.b=C9e2KlVV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728908AbfCVRrT (ORCPT + 99 others); Fri, 22 Mar 2019 13:47:19 -0400 Received: from a9-34.smtp-out.amazonses.com ([54.240.9.34]:41658 "EHLO a9-34.smtp-out.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727871AbfCVRrT (ORCPT ); Fri, 22 Mar 2019 13:47:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=6gbrjpgwjskckoa6a5zn6fwqkn67xbtw; d=amazonses.com; t=1553276838; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:MIME-Version:Content-Type:Feedback-ID; bh=rFwzn/BBO25AP0s77MXmb0hXGtOvd/fOwhwfuRoZrBw=; b=C9e2KlVV2mDdwR48uPojXdogeRsWVjBuGjnXSR99D/1/hWBT97akhkkrahqu9rfV nN5akCDSy2A3KAjstu1nDudPH1zBtFR02pVvL1AikDrtcJvXvztaWo8qYvkiIriJfTL NBMJ+uk3vWOjFYWC7WnzRVoNt+tbkkEx+reCBk/c= Date: Fri, 22 Mar 2019 17:47:18 +0000 From: Christopher Lameter X-X-Sender: cl@nuc-kabylake To: Waiman Long cc: Andrew Morton , Pekka Enberg , David Rientjes , Joonsoo Kim , linux-kernel@vger.kernel.org, linux-mm@kvack.org, selinux@vger.kernel.org, Paul Moore , Stephen Smalley , Eric Paris , "Peter Zijlstra (Intel)" , Oleg Nesterov Subject: Re: [PATCH 1/4] mm: Implement kmem objects freeing queue In-Reply-To: <20190321214512.11524-2-longman@redhat.com> Message-ID: <01000169a683a0ed-3fa1b014-8efa-4c8f-a7e1-958e9eccd693-000000@email.amazonses.com> References: <20190321214512.11524-1-longman@redhat.com> <20190321214512.11524-2-longman@redhat.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-SES-Outgoing: 2019.03.22-54.240.9.34 Feedback-ID: 1.us-east-1.fQZZZ0Xtj2+TD7V5apTT/NrT6QKuPgzCT/IC7XYgDKI=:AmazonSES Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 21 Mar 2019, Waiman Long wrote: > When releasing kernel data structures, freeing up the memory > occupied by those objects is usually the last step. To avoid races, > the release operation is commonly done with a lock held. However, the > freeing operations do not need to be under lock, but are in many cases. > > In some complex cases where the locks protect many different memory > objects, that can be a problem especially if some memory debugging > features like KASAN are enabled. In those cases, freeing memory objects > under lock can greatly lengthen the lock hold time. This can even lead > to soft/hard lockups in some extreme cases. > > To make it easer to defer freeing memory objects until after unlock, > a kernel memory freeing queue mechanism is now added. It is modelled > after the wake_q mechanism for waking up tasks without holding a lock. It is already pretty easy. You just store the pointer to the slab object in a local variable, finish all the unlocks and then free the objects. This is done in numerous places of the kernel. I fear that the automated mechanism will make the code more difficult to read and result in a loss of clarity of the sequencing of events in releasing locks and objects. Also there is already kfree_rcu which does a similar thing to what you are proposing here and is used in numerous places.