Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2767895rwb; Fri, 2 Dec 2022 14:58:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf43ZAAr/IHMGfQQgw40bAigqkLzTvKSV3i7Z0a9zsClsZAXWV6UqmKUSRwRrtX9q4JoYKEC X-Received: by 2002:a17:907:7e86:b0:7af:bc9:5e8d with SMTP id qb6-20020a1709077e8600b007af0bc95e8dmr62939003ejc.3.1670021933559; Fri, 02 Dec 2022 14:58:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670021933; cv=none; d=google.com; s=arc-20160816; b=c623aLewuyishzAihRMxFIgJRpdBFNQHssVDX+q5CJJ6sTbbG3lrbj30KnBiWpFk+j zBA6x0JddYE+UAAc0WB/Hsi7mJjG4dqE8mnULY/0xUVhqDgJcWcExQGRbkdRfGBCCagT c8+wDbmXow6V7YQF1WoGM0FWF72EB+FA880INvDh/bAAypdH3BDnlHx3J0bLj1yyNqzR 6cDiO71URZzB6OVbEYq5zTEuzUxgOq0C4QfRaFLAqA3O0OSOofnuwKsbh9cHuo3UQsN8 D4bGV4TUEiYtnhKO6+6f2htnk/hCMJX5ILl+h52WkUvbmIBP/zL9JIZCovsxxgNTSAp9 1WqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=zf9FQYPb7IhTgwhWHe3ZzCAFF6zYBHHq7kdqxOUK6iE=; b=nWS0J8GyzauOWVDwxscN2hVN45zc5KuRDVM6WecMIW4pa5Z+7/1KFLtvT7xxEHx71j /H+MI/I0P7jy6UMM3WArQz3xOf2WCebv4MkOXQq9+y827eCHO6dsB5KdwjO2u1ivE4xJ CTAlFQ4K2sHyVIgKZ4w9o2S07VSY8W4S2PV8Hjfn//KL2WMw5KDhCmLFKx6nina2dBGw wPKi4BPYeQFm5M72+ScVE0l93Wh4vbqXzUy1rjNztSRsnwDoqGb0uLP7PmR1o6UQOORK x/h86JKPFy11vRNbR33vyywjfUPx1wfe19oydlhlgtRgRKDZUKOIWqoGlbBktlYyPpCz htyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=oNLuBgJV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bc14-20020a056402204e00b0045d292ef641si4495550edb.493.2022.12.02.14.58.33; Fri, 02 Dec 2022 14:58:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=oNLuBgJV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234200AbiLBWty (ORCPT + 83 others); Fri, 2 Dec 2022 17:49:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233637AbiLBWtv (ORCPT ); Fri, 2 Dec 2022 17:49:51 -0500 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC4FE5F5F for ; Fri, 2 Dec 2022 14:49:50 -0800 (PST) Received: by mail-pj1-x102d.google.com with SMTP id w15-20020a17090a380f00b0021873113cb4so6422902pjb.0 for ; Fri, 02 Dec 2022 14:49:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=zf9FQYPb7IhTgwhWHe3ZzCAFF6zYBHHq7kdqxOUK6iE=; b=oNLuBgJV9pADQi48wDLKc0aHYvcSFy+n64QtfRVE9Qvx5jIC11Gt51rOMETOQtkv03 Z0DdLrYHUrjE6AdeCCYWYFCYeMIsQ72e9HoEC8r38Zbxx0WaQrTx24PhhcISBUgIm7zN xy/lbDoWZw2Rid+3mwGaiU9YQSqJYu0o0Sda8PTfuMr1O5MOm0ZY/LZIaU83W223zhlz H7bzOPrBMii4m5EvjoJLYdUryrPyA3YUDEVofre1+SCmjewkhBlw2C2QOruYvYJnO4u2 Q46PLNHcHnErGYNtJXbMc11k8/1mcmB9/epIn99dnC8IssY4IA6QGx+WDnN/X6U0phEw 9WBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=zf9FQYPb7IhTgwhWHe3ZzCAFF6zYBHHq7kdqxOUK6iE=; b=KpoL4uWmHZgJXD/vy645Sdp42/imokMLlM+mzVh9QCS2s6wPaGlAopIaX9OKQucUNY 7aEvkDpVWym/BQ7T7IRQ/HAzTT1E6FwANX9A7KE0Qx+ZsOmtJmrSQplKieGW8TbguIad 0defzHsKpC/Y66kRwjXtPXjsBJnLK7FNHEhVp8ElBOI6hGC/p+Xrp5nFyjKZ/7AYjB0/ OcG54aqsEj9D6JBs/RBCpf+1yLvwT9JT8X5YGonlR0MQRkTZbcAb265ulXsRp/SIGhNu xHIlUm9++rwQBwLP90AXavmDyIpZPPYhBS5tXXyydlimdF5WGVFneD0aKcSLQAArM7IJ 18cw== X-Gm-Message-State: ANoB5plnA33uMK5OkjJvnDIdcvQJ+TU/1bFIsugNLdqUteAorpnaJWmR Fr5TfCsGfSi2yJVVkta+E+4qxg== X-Received: by 2002:a17:902:ecd1:b0:189:90b9:2500 with SMTP id a17-20020a170902ecd100b0018990b92500mr25315753plh.0.1670021390123; Fri, 02 Dec 2022 14:49:50 -0800 (PST) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id g81-20020a625254000000b00561d79f1064sm5585756pfb.57.2022.12.02.14.49.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 14:49:49 -0800 (PST) Date: Fri, 2 Dec 2022 22:49:46 +0000 From: Sean Christopherson To: Dave Hansen Cc: Kristen Carlson Accardi , jarkko@kernel.org, dave.hansen@linux.intel.com, tj@kernel.org, linux-kernel@vger.kernel.org, linux-sgx@vger.kernel.org, cgroups@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , zhiquan1.li@intel.com Subject: Re: [PATCH v2 02/18] x86/sgx: Store struct sgx_encl when allocating new VA pages Message-ID: References: <20221202183655.3767674-1-kristen@linux.intel.com> <20221202183655.3767674-3-kristen@linux.intel.com> <3a789b1c-4c70-158b-d764-daec141a5816@intel.com> <2015ae96-5459-1f82-596b-f46af08ef766@intel.com> <8b7f6993-2135-a9f9-63c5-c9c6112ef676@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8b7f6993-2135-a9f9-63c5-c9c6112ef676@intel.com> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 02, 2022, Dave Hansen wrote: > On 12/2/22 14:35, Sean Christopherson wrote: > >> That seems like it's going the other direction from what an OOM-kill > >> would need to do. > > Providing a backpointer from a VA page to its enclave allows OOM-killing the enclave > > if its cgroup is over the limit but there are no reclaimable pages for said cgroup > > (for SGX's definition of "reclaimable"). I.e. if all of an enclave's "regular" > > pages have been swapped out, the only thing left resident in the EPC will be the > > enclave's VA pages, which are not reclaimable in the kernel's current SGX > > implementation. > > Ooooooooooooooooooooh. I'm a dummy. > > > So, we've got a cgroup. It's in OOM-kill mode and we're looking at the > *cgroup* LRU lists. We've done everything we can to the enclave and > swapped everything out that we can. All we're left with are these > crummy VA pages on the LRU (or equally crummy pages). We want to > reclaim them but can't swap VA pages. Our only recourse is to go to the > enclave and kill *it*. > > Right now, we can easily find an enclave's VA pages and free them. We > do that all the time when freeing whole enclaves. But, what we can't > easily do is find an enclave given a VA page. > > A reverse pointer from VA page back to enclave allows the VA page's > enclave to be located and efficiently killed. > > Right? Yep, exactly.