Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3345853img; Mon, 25 Mar 2019 08:27:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMXxJ0J940Dx/cui1Kqks+9ITAJ7E9xt3Mx1k7F3emmSBCLf1A07BHVF+rnYvkV16l/z2D X-Received: by 2002:a17:902:7c8c:: with SMTP id y12mr6635839pll.209.1553527666206; Mon, 25 Mar 2019 08:27:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553527666; cv=none; d=google.com; s=arc-20160816; b=NDZ8CaO5wlVmpbDIdxW1HZk3jKrG4BX8X+s42MtnbIGQ2tdSt4ccw87VuCqREKeTxp mfIhC8VmfflvrNd4N6KLm4vGzYqGX3F0LkJlKXjFFPkxJRjzg5C1q0jsT52+WQDIOUDI AZ/PdYaUmn9MzlXDU8BqcsOV/TOJpppeOhVlCUov1YS+qR7LqWKxNPlopcyX8yyFgcgB 9uKBWRWcn8Wji0GemMwMiTMf7qFObfnfg5aXrECz6+h/dhhmoxTPW2RT60mSSqwrHNgX T+kye7UNd5pKu92obv6ShC48k/SzzyAnSK6TT9hWkw7P1YYKk3AhsI+i7oshJcTvyYoN HoMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=D8ZVArfnFLBcVmlAcDBorEaZjH66v1dusWAAyZwbrQw=; b=x4mRpzCfDgbLFfqYxdkVCEKiVDeMI8ZA23tIGhMvYvLGoG0ojTw6qD8UfZmfYYJ+0q jAXC7Sm1WCKJpCSDVsGFsViAirOeCVYOpeBnGRQJi8LUdKLd7DN6LxL8Nt7IrHdONVTi sWEhzFmW7jWWUJQOPrlAV0k9DBCyb8RJH3tzBQSvc1uvjWmimOrnCdq1NlrSEa4touf0 PJT9soLR9eznQ96h6nO4+mqF+5uKUxDh8MYNB8uOkWCm7/Oxiqx3UtAE3ByaFjN1QYrH 8jJ4PPvT3fWTOoiZyf2d1EhsQQyZpNdVkBOhYeRlNZQ70Tcs7+kw/pEYtrBdsgq6wUY+ PFSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=IpLumw3U; 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 j71si14068143pfc.280.2019.03.25.08.27.31; Mon, 25 Mar 2019 08:27:46 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=IpLumw3U; 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 S1729549AbfCYP0e (ORCPT + 99 others); Mon, 25 Mar 2019 11:26:34 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:48084 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726743AbfCYP0e (ORCPT ); Mon, 25 Mar 2019 11:26:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=D8ZVArfnFLBcVmlAcDBorEaZjH66v1dusWAAyZwbrQw=; b=IpLumw3UrLhH6QfeKSA8vQdAz yTGI0GJFGhrgB77kTlyDPnn1vmjAdz4nLUBoVyTnVbPpH6JVZV0cTxUnBWzuah4Y2enj03N6JEM9E LBc2CvIGi1DrS4KTI31rFTtOKpixQafa2pmUTouq9V9uL8SOnXcphOyKFuV9paW7x4O+wLMLlHFU8 3aoBTt/5WpXWs0qXlIZyjtiEC8Yp9rJDVcXKAHh/qyr4uTgKS+MTn1LOP4U2G5KrxBIGCcxFrK37S 767Tlo0LOq4V7Lb7S9Yj7B0IDy4t87ymWvxPQ53U8ClZteR6RCav/Ml3K4D6shqcmCKPpNJiSBX4i 2Yv7HGmqw==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1h8RUM-0003TH-7G; Mon, 25 Mar 2019 15:26:14 +0000 Date: Mon, 25 Mar 2019 08:26:14 -0700 From: Matthew Wilcox To: Christopher Lameter Cc: Waiman Long , Oleg Nesterov , 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)" Subject: Re: [PATCH 2/4] signal: Make flush_sigqueue() use free_q to release memory Message-ID: <20190325152613.GG10344@bombadil.infradead.org> References: <20190321214512.11524-1-longman@redhat.com> <20190321214512.11524-3-longman@redhat.com> <20190322015208.GD19508@bombadil.infradead.org> <20190322111642.GA28876@redhat.com> <01000169a686689d-bc18fecd-95e1-4b3e-8cd5-dad1b1c570cc-000000@email.amazonses.com> <93523469-48b0-07c8-54fd-300678af3163@redhat.com> <01000169a6ea5e46-f845b8db-730b-436e-980c-3e4273ad2e34-000000@email.amazonses.com> <20190322195926.GB10344@bombadil.infradead.org> <01000169b534b9e8-31a2af2c-c396-47f9-8534-4cbd934ef09d-000000@email.amazonses.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <01000169b534b9e8-31a2af2c-c396-47f9-8534-4cbd934ef09d-000000@email.amazonses.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 25, 2019 at 02:15:25PM +0000, Christopher Lameter wrote: > On Fri, 22 Mar 2019, Matthew Wilcox wrote: > > > On Fri, Mar 22, 2019 at 07:39:31PM +0000, Christopher Lameter wrote: > > > On Fri, 22 Mar 2019, Waiman Long wrote: > > > > > > > > > > > > >> I am looking forward to it. > > > > > There is also alrady rcu being used in these paths. kfree_rcu() would not > > > > > be enough? It is an estalished mechanism that is mature and well > > > > > understood. > > > > > > > > > In this case, the memory objects are from kmem caches, so they can't > > > > freed using kfree_rcu(). > > > > > > Oh they can. kfree() can free memory from any slab cache. > > > > Only for SLAB and SLUB. SLOB requires that you pass a pointer to the > > slab cache; it has no way to look up the slab cache from the object. > > Well then we could either fix SLOB to conform to the others or add a > kmem_cache_free_rcu() variant. The problem with a kmem_cache_free_rcu() variant is that we now have three pointers to store -- the object pointer, the slab pointer and the rcu next pointer. I spent some time looking at how SLOB might be fixed, and I didn't come up with a good idea. Currently SLOB stores the size of the object in the four bytes before the object, unless the object is "allocated from a slab cache", in which case the size is taken from the cache pointer instead. So calling kfree() on a pointer allocated using kmem_cache_alloc() will cause corruption as it attempts to determine the length of the object. Options: 1. Dispense with this optimisation and always store the size of the object before the object. 2. Add a kmem_cache flag that says whether objects in this cache may be freed with kfree(). Only dispense with this optimisation for slabs with this flag set. 3. Change SLOB to segregate objects by size. If someone has gone to the trouble of creating a kmem_cache, this is a pretty good hint that there will be a lot of objects of this size allocated, so this could help SLOB fight fragmentation. Any other bright ideas?