Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1361064pxk; Thu, 10 Sep 2020 13:29:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnJhXL8mCbr5vcsWQ9NYEBWiwY1Tz1BNERlWRtbJe5C4I1m2EjaQW2y+A2hncVlSRhRO4o X-Received: by 2002:a17:906:4993:: with SMTP id p19mr11206938eju.277.1599769754194; Thu, 10 Sep 2020 13:29:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599769754; cv=none; d=google.com; s=arc-20160816; b=VfGjoSPZmqz0V7jj0IXsdZBSfTqphvrgJcrKLIMqk2nrp0jf84+SrJCqe1/y5HfmE4 eVLELkk1j0mSQ4cARb/HMyQ3DRNfUhnpl1MRO6W2/lseBkKJHev+akzIFUpmr7mZJMz0 ynw+EqtPq+ah2ILzkLkeifIRTnYJToQ8PadjRiArMcvF8k2OO8XOFeF4ydq9Eo/hhFjo hJFkRVFp/paKcR9o2Q8oyg73YVGapcPc5QbIFzkaoAueuxqGw/1kBjq9J6pj8XijGIOt RaGOn1fL+xmrHlrcVngGG5xc7zzp324FPRzPwJg4f2R9/sMWzkOamTztar/QJ6KMqS4A gXRg== 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:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=pcMZpcyT0RX6WRJ/eVgBw1q/30QSiMDMGqssPVfjeUk=; b=pbux0oqmV2xMfN97ROrEUVFPBdXmvOLSTch/4IQk6j8ABVoa6/MXTZQNhvJAaYB3wO S0B0ea/q4kkhKyYmfGjd6PGabuefa7/s8hOY5DbCT1sMCmiUqoXcpCsx8AZjneajztQf 1I3Sabe4jbiuc19n3A/pDMJdm4nf/xgpbEo9MoKSxSiNIXUlFHFgRWR6yFyV/WDBwaq2 HyVaJ+q8xCQDwWCCsh0gABRNen8TXs3uXNPWQtHmJsxh1+YfhgkqnVO9Tp15dAyiz/ej hofBCVzXI0RK3DcnpZKW4MeklkrgwoOqbh6t/NArdh66EgU5IqkZfcMUsarFtex5wFtX a5FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=doPdBnJs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w23si4519481ejy.456.2020.09.10.13.28.51; Thu, 10 Sep 2020 13:29:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=doPdBnJs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725913AbgIJU01 (ORCPT + 99 others); Thu, 10 Sep 2020 16:26:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:53384 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726267AbgIJUZ2 (ORCPT ); Thu, 10 Sep 2020 16:25:28 -0400 Received: from paulmck-ThinkPad-P72.home (unknown [50.45.173.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4E83E20829; Thu, 10 Sep 2020 20:25:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599769527; bh=j1D8IPJ4Y08qnoWlFLiDNLrabhQVaPZSJO9zVTmslg8=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=doPdBnJsbif/E+6P+b8WZBM0DPFyC8Ar2wQffAXUnGxFuH8CuQy6cIoH1ChJxEEdp T/094BXQngRogk0hZw0MrLqFPTkSpdB3jz95pU+oOeYJExyZ+BkHTDqXzi+TVSEyPF W22Q8DV32RdLZ+Yl4WNrQphSoWVZuPu3oZHwDtKg= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id CF0923523080; Thu, 10 Sep 2020 13:25:26 -0700 (PDT) Date: Thu, 10 Sep 2020 13:25:26 -0700 From: "Paul E. McKenney" To: Dmitry Vyukov Cc: Alexander Potapenko , Marco Elver , Andrew Morton , Catalin Marinas , Christoph Lameter , David Rientjes , Joonsoo Kim , Mark Rutland , Pekka Enberg , "H. Peter Anvin" , Andrey Konovalov , Andrey Ryabinin , Andy Lutomirski , Borislav Petkov , Dave Hansen , Eric Dumazet , Greg Kroah-Hartman , Ingo Molnar , Jann Horn , Jonathan Corbet , Kees Cook , Peter Zijlstra , Qian Cai , Thomas Gleixner , Will Deacon , the arch/x86 maintainers , "open list:DOCUMENTATION" , LKML , kasan-dev , Linux ARM , Linux-MM Subject: Re: [PATCH RFC 01/10] mm: add Kernel Electric-Fence infrastructure Message-ID: <20200910202526.GU29330@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20200907134055.2878499-1-elver@google.com> <20200907134055.2878499-2-elver@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 10, 2020 at 07:11:41PM +0200, Dmitry Vyukov wrote: > On Thu, Sep 10, 2020 at 6:19 PM Alexander Potapenko wrote: > > > > On Thu, Sep 10, 2020 at 5:43 PM Dmitry Vyukov wrote: > > > > > > > > + /* Calculate address for this allocation. */ > > > > + if (right) > > > > + meta->addr += PAGE_SIZE - size; > > > > + meta->addr = ALIGN_DOWN(meta->addr, cache->align); > > > > > > I would move this ALIGN_DOWN under the (right) if. > > > Do I understand it correctly that it will work, but we expect it to do > > > nothing for !right? If cache align is >PAGE_SIZE, nothing good will > > > happen anyway, right? > > > The previous 2 lines look like part of the same calculation -- "figure > > > out the addr for the right case". > > > > Yes, makes sense. > > > > > > + > > > > + schedule_delayed_work(&kfence_timer, 0); > > > > + WRITE_ONCE(kfence_enabled, true); > > > > > > Can toggle_allocation_gate run before we set kfence_enabled? If yes, > > > it can break. If not, it's still somewhat confusing. > > > > Correct, it should go after we enable KFENCE. We'll fix that in v2. > > > > > > +void __kfence_free(void *addr) > > > > +{ > > > > + struct kfence_metadata *meta = addr_to_metadata((unsigned long)addr); > > > > + > > > > + if (unlikely(meta->cache->flags & SLAB_TYPESAFE_BY_RCU)) > > > > > > This may deserve a comment as to why we apply rcu on object level > > > whereas SLAB_TYPESAFE_BY_RCU means slab level only. > > > > Sorry, what do you mean by "slab level"? > > SLAB_TYPESAFE_BY_RCU means we have to wait for possible RCU accesses > > in flight before freeing objects from that slab - that's basically > > what we are doing here below: > > Exactly! You see it is confusing :) > SLAB_TYPESAFE_BY_RCU does not mean that. rcu-freeing only applies to > whole pages, that's what I mean by "slab level" (whole slabs are freed > by rcu). Just confirming Dmitry's description of SLAB_TYPESAFE_BY_RCU semantics. Thanx, Paul