Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp217658imj; Wed, 13 Feb 2019 07:13:56 -0800 (PST) X-Google-Smtp-Source: AHgI3IZT+Shj2gtISdDuZT1Yms/RjYCvLOxLmQOOEqCVqZf4lp7TyvG7LyFXF+EoXtNKgv2jHCU0 X-Received: by 2002:a17:902:1aa:: with SMTP id b39mr1039145plb.244.1550070836202; Wed, 13 Feb 2019 07:13:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550070836; cv=none; d=google.com; s=arc-20160816; b=T73sgaXt7PKFZPbNRageRe4ippDFcyuRdaL0uomgKfvujVWrKzzJY5LjM9MzJmouUQ ZS2ccSkdusvXYBZKWe/K8bnlaSCMJsJ6dohvhUD+d+7w6ScMHBtl9j2pnho6dEVoryNW LJUF5yxskF3t5kiIT0IzO1y6SURmOZsajt9jZCqNcXafYfdjInDc/xmkYhZ0IZt9+tP1 RIUOehHDnB/5qExdJvORKwRm5ePB+DAyU8yR/8ltFMy8OfoeKksiitKy7X0wIC/rIMqP e2SO5E/3nSTXR6QInP+hzSvxnjL9vMspGCoAtuorfgrvaFNzCNt1zSTdw1SrNPF+9ZSp q3qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=P1j1RvdZA+9HZ4z+gupJAUzP+Cw/+xffkNO3SkkGnz4=; b=oH8BE5hAvlhh8BZy0logCR0aB5miUxtovBLLusBrvDgv7eoaUq4RZ5xdhZ+uIfsVKV F0KRyj77nVRgAOJDx5onfn05ksWidmdYVnkXtrgqGXK/kVj4XMxncrkY1z04qUTr/isG 7Z+LnLjASYiSKw6u8VuMJdW/RA9/okEjsBBhkJwD5cJQuUHRUUwxR0qItjf/pcQXNF9Q qfvQgMV7FhLxTgktQq7U3YcroJNDT/kvDoDwTC10pJtkUSMYEcLF4b+ZrRhtBL3B0n1s Hy2d+EakkS4VjZ2M66rY06b7YmYA7/STc1ntLr1S8pfJ7+Ki00qIiR3o6FVFaOpXUMoE 35ew== ARC-Authentication-Results: i=1; mx.google.com; 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 z17si13063601pgf.267.2019.02.13.07.13.38; Wed, 13 Feb 2019 07:13:56 -0800 (PST) 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; 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 S2388401AbfBMONd convert rfc822-to-8bit (ORCPT + 99 others); Wed, 13 Feb 2019 09:13:33 -0500 Received: from eu-smtp-delivery-151.mimecast.com ([207.82.80.151]:56373 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728416AbfBMONc (ORCPT ); Wed, 13 Feb 2019 09:13:32 -0500 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-110-WxTaH3GeMhar7JZtKQUZtw-1; Wed, 13 Feb 2019 14:12:56 +0000 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b::d117) by AcuMS.aculab.com (fd9f:af1c:a25b::d117) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Wed, 13 Feb 2019 14:13:08 +0000 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Wed, 13 Feb 2019 14:13:08 +0000 From: David Laight To: 'Peter Zijlstra' , Vineet Gupta CC: Alexey Brodkin , "linux-snps-arc@lists.infradead.org" , Arnd Bergmann , "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" , Mark Rutland Subject: RE: [PATCH] ARC: Explicitly set ARCH_SLAB_MINALIGN = 8 Thread-Topic: [PATCH] ARC: Explicitly set ARCH_SLAB_MINALIGN = 8 Thread-Index: AQHUwvc8KjF6Xlwy10OvbYFx5kwo16XcaZhggAFH5CCAABKpkA== Date: Wed, 13 Feb 2019 14:13:08 +0000 Message-ID: <536eb8d0112b44dc90b9b9a7f670e96d@AcuMS.aculab.com> References: <20190208105519.26750-1-abrodkin@synopsys.com> <81017fe4-b31f-4942-e822-a7b70008b74d@synopsys.com> <20190213125651.GP32494@hirez.programming.kicks-ass.net> In-Reply-To: <20190213125651.GP32494@hirez.programming.kicks-ass.net> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-MC-Unique: WxTaH3GeMhar7JZtKQUZtw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Zijlstra > Sent: 13 February 2019 12:57 ... ... > In the past I've proposed a GCC plugin / checker that would verify the > alignment requirements against the various allocators. > > For instance: > > struct foo { > spinlock_t a; > int b; > } __cacheline_aligned; > > struct foo *my_foo = kmalloc(sizeof(struct foo), GFP_KERNEL); > > would result in a warning; because obviously kmalloc (as per > ARCH_SLAB_MINALIGN) doesn't respect the cacheline alignment of the type. > > Of course; it appears our kmalloc() function definition doesn't even > have a __malloc attribute, so there's plenty work to be done here. We could pass the alignment to the allocator by defining something like: #define do_malloc(x) ((x) = (typeof(*(x)))_do_malloc(sizeof *(x), __alignof__(*(x)))) Although you probably want to compile-time detect alignments that are smaller than the normal minimal alignment. If the allocator needs to add a header it would need to use the byte before the allocated item to find the header. OTOH adding a header is horrid for page-sized items. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)