public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: William Lee Irwin III <wli@holomorphy.com>
To: linux-kernel@vger.kernel.org
Subject: [3/11] hugetlb: wrap release path with release_key()
Date: Tue, 12 Nov 2002 00:28:53 -0800	[thread overview]
Message-ID: <E18BWPl-0005KA-00@holomorphy> (raw)

This wraps the release path in alloc_shared_hugetlb_pages() with a
release_key() function that handles the release.

 hugetlbpage.c |   31 ++++++++++++++++++++-----------
 1 files changed, 20 insertions(+), 11 deletions(-)


diff -urpN htlb-2.5.47-2/arch/i386/mm/hugetlbpage.c htlb-2.5.47-3/arch/i386/mm/hugetlbpage.c
--- htlb-2.5.47-2/arch/i386/mm/hugetlbpage.c	2002-11-11 21:08:00.000000000 -0800
+++ htlb-2.5.47-3/arch/i386/mm/hugetlbpage.c	2002-11-11 21:23:55.000000000 -0800
@@ -101,6 +101,23 @@ struct hugetlb_key *alloc_key(int key, u
 	return (struct hugetlb_key *)inode;
 }
 
+static void release_key(struct hugetlb_key *key)
+{
+	int i;
+	struct inode *inode = (struct inode *)key;;
+
+	spin_lock(&htlbpage_lock);
+	for(i = 0;i < MAX_ID; ++i)
+		if (htlbpagek[i].key != inode->i_ino)
+			continue;
+
+	BUG_ON(i >= MAX_ID);
+	htlbpagek[i].key = 0;
+	htlbpagek[i].in = NULL;
+	kfree(inode);
+	spin_unlock(&htlbpage_lock);
+}
+
 static struct page *alloc_hugetlb_page(void)
 {
 	int i;
@@ -339,7 +356,6 @@ static int alloc_shared_hugetlb_pages(in
 	struct vm_area_struct *vma;
 	struct inode *inode;
 	struct address_space *mapping;
-	int idx;
 	int retval = -ENOMEM;
 	int newalloc = 0;
 
@@ -390,16 +406,9 @@ out:
 	return retval;
 out_err: spin_unlock(&htlbpage_lock);
 freeinode:
-	 if (newalloc) {
-		 for(idx=0;idx<MAX_ID;idx++)
-			 if (htlbpagek[idx].key == inode->i_ino) {
-				 htlbpagek[idx].key = 0;
-				 htlbpagek[idx].in = NULL;
-				 break;
-			 }
-		 kfree(inode);
-	 }
-	 return retval;
+	if (newalloc)
+		release_key((struct hugetlb_key *)inode);
+	return retval;
 }
 
 int hugetlb_prefault(struct address_space *mapping, struct vm_area_struct *vma)

                 reply	other threads:[~2002-11-12  8:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E18BWPl-0005KA-00@holomorphy \
    --to=wli@holomorphy.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox