Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp541727ima; Fri, 26 Oct 2018 02:32:57 -0700 (PDT) X-Google-Smtp-Source: AJdET5dxCnUSVBqZSrBG6OwuqsXxOjnZn1V3bjLKbi0fm2W4x/9fabGGQBAdC6v9ynMfFYKd+QIp X-Received: by 2002:a63:e256:: with SMTP id y22-v6mr2712935pgj.439.1540546377442; Fri, 26 Oct 2018 02:32:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540546377; cv=none; d=google.com; s=arc-20160816; b=ctsrnQuU0S5uS+W1pPCdhTamIbmcvCBSEkAgz1dPEioVBRT6S+0vJnb4Pk70il01++ X77hy+R5QRxnuSPI0iZQJrE4ocyGV05vHMQDywC031ECcvbw+sQ0ukAjLFSx+VqQZvBo 8U5wVTOExN1aBZNPJx3W57vXgWTMMBHUH7slXi4rWvzEXdAUe9COAy6Zm003+CcONQVM dK6IGhDryYLAvTIch1tjJm0aIzAXFSkVy/0kfcamSqUqyMaecwnkJlOLiB3AQaeGkAzm lrl3QbqUp4dTsKO38Rq5G0otjptsRGRfgyW2PpUhNU5tCitFADQQKzr1kCLXkxyhmwfD ZjMQ== 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=Flwloc/RXwyekTLnRQWtL8hKTHk4sO/+tf4eemj4N/8=; b=yN31+0+NQUCN7qHYQwvQZ5VkEqMLP9wk4SaIEKMtW1GFeb4bXsDK4fkOO6pBjud1wQ 6cxPjsnRRNKCSKk4KVZin0CSJUx8ozGcDkDNiV6h31+LoBJBZSqU1FP5s9ZNzz0pNXJa Ish/PPLQLdCHNnvDJ73B/89e5VB++eA52HgK2qX9gC1jYHJX7wJxV6Tg/Z9+7k6L6WE7 Xfd7GIUfoXaB1SWOd8YfTBJN6ac8P64zNkgdCOAYFkhfkagaEaWof8GZ69KjbIIw2Lhm sDj4D23midBcwvdUc61h4mIbf3HSkNu08VZ+3qVVI3hhes+IrBeucjpoeF+7o2JQEyIa 4fAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=JBVbhtkX; 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 o13-v6si10573141pgh.61.2018.10.26.02.32.40; Fri, 26 Oct 2018 02:32:57 -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=merlin.20170209 header.b=JBVbhtkX; 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 S1727224AbeJZSIU (ORCPT + 99 others); Fri, 26 Oct 2018 14:08:20 -0400 Received: from merlin.infradead.org ([205.233.59.134]:60898 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726128AbeJZSIU (ORCPT ); Fri, 26 Oct 2018 14:08:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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=Flwloc/RXwyekTLnRQWtL8hKTHk4sO/+tf4eemj4N/8=; b=JBVbhtkXD4liY1/FC72eP/K8Y qdxheF3aUiRM/BaZiS+pD2ZCLuoxiAPhUjDBK7qBE/JgnmBwt/pQqctpanIF7qVcarV9AMmCoGpHt 0zGcsg/o6Lwf8SwQTfyphP6dkSTgdXEO/+GAZigeCB1VLK91Lb8XglxkA8RrmNTraU9scmO6rUSuM 0YXHimbrxH+OGxkUWVo933P4Ph+FAxk6uCmI0cK9mKeoolEkWYidrvEJiD3Up0GFFWyVxrtL0/UYG cuiLMCAfVEQ5DyXZ5m9wRmpC5TpEUTxuwBsesjJzj9wYaaft4itIvI/zM6jixa25fuK49XnEyLphW OJxb6+UYw==; Received: from [167.98.65.38] (helo=worktop) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gFySm-00017Q-IQ; Fri, 26 Oct 2018 09:31:28 +0000 Received: by worktop (Postfix, from userid 1000) id A334F6E07BE; Fri, 26 Oct 2018 11:31:26 +0200 (CEST) Date: Fri, 26 Oct 2018 11:31:26 +0200 From: Peter Zijlstra To: Igor Stoppa Cc: Mimi Zohar , Kees Cook , Matthew Wilcox , Dave Chinner , James Morris , Michal Hocko , kernel-hardening@lists.openwall.com, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, igor.stoppa@huawei.com, Dave Hansen , Jonathan Corbet , Laura Abbott , Greg Kroah-Hartman , Andrew Morton , Masahiro Yamada , Alexey Dobriyan , Pekka Enberg , "Paul E. McKenney" , Lihao Liang , linux-kernel@vger.kernel.org Subject: Re: [PATCH 12/17] prmem: linked list: set alignment Message-ID: <20181026093126.GC3159@worktop.c.hoisthospitality.com> References: <20181023213504.28905-1-igor.stoppa@huawei.com> <20181023213504.28905-13-igor.stoppa@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181023213504.28905-13-igor.stoppa@huawei.com> User-Agent: Mutt/1.5.22.1 (2013-10-16) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 24, 2018 at 12:34:59AM +0300, Igor Stoppa wrote: > As preparation to using write rare on the nodes of various types of > lists, specify that the fields in the basic data structures must be > aligned to sizeof(void *) > > It is meant to ensure that any static allocation will not cross a page > boundary, to allow pointers to be updated in one step. > > Signed-off-by: Igor Stoppa > CC: Greg Kroah-Hartman > CC: Andrew Morton > CC: Masahiro Yamada > CC: Alexey Dobriyan > CC: Pekka Enberg > CC: "Paul E. McKenney" > CC: Lihao Liang > CC: linux-kernel@vger.kernel.org > --- > include/linux/types.h | 20 ++++++++++++++++---- > 1 file changed, 16 insertions(+), 4 deletions(-) > > diff --git a/include/linux/types.h b/include/linux/types.h > index 9834e90aa010..53609bbdcf0f 100644 > --- a/include/linux/types.h > +++ b/include/linux/types.h > @@ -183,17 +183,29 @@ typedef struct { > } atomic64_t; > #endif > > +#ifdef CONFIG_PRMEM > struct list_head { > - struct list_head *next, *prev; > -}; > + struct list_head *next __aligned(sizeof(void *)); > + struct list_head *prev __aligned(sizeof(void *)); > +} __aligned(sizeof(void *)); > > -struct hlist_head { > - struct hlist_node *first; > +struct hlist_node { > + struct hlist_node *next __aligned(sizeof(void *)); > + struct hlist_node **pprev __aligned(sizeof(void *)); > +} __aligned(sizeof(void *)); Argh.. are we really supporting platforms that do not naturally align this? If so, which and can't we fix those? Also, if you force alignment on a member, the structure as a whole inherits the largest member alignment. Also, you made something that was simple an unreadable mess without proper justification (ie. you fail to show need).